apiVersion: v1
kind: Pod
metadata:
  name: fortune-configmap-volume
  namespace: chp07-set746
  labels:
    app: fortune-configmap-volume
spec:
  # volumes go in spec.volumes
  volumes:
  - name: html 
    emptyDir: {}
  - name: config
    # This volume references the fortune-config ConfigMap
    configMap:
      name: fortune-config
      # populate configMap volume with only entries under this key
      items:
      - key: my-nginx-config.conf
        # value of entry stored in this file
        path: gzip.conf
      defaultMode: 0666

  containers:
  - image: georgebaptista/fortune:env
    name: html-generator
    volumeMounts:
    - name: html
      mountPath: /var/htdocs
    env:
    - name: INTERVAL
      valueFrom:
        configMapKeyRef:
          name: fortune-config
          key: sleep-interval

  - image: nginx:alpine
    name: web-server
    volumeMounts:
      # refer to emptyDir html
    - name: html
      mountPath: /usr/share/nginx/html
      readOnly: true

      # refer to configMap fortune-config
    - name: config
      mountPath: /etc/nginx/conf.d
      readOnly: true 

      # refer to configMap fortune-config
    - name: config
      mountPath: /tmp/whole-fortune-config-volume
      readOnly: true

    ports:
    - containerPort: 80
      protocol: TCP

