# Environment variables picked up from a ConfigMap
---
apiVersion: v1
kind: Pod
metadata:
  name: random-generator
  labels:
    app: random-generator
spec:
  containers:
  - image: k8spatterns/random-generator:1.0
    name: random-generator
    env:
    # Configure Spring boot to pick up that configuration coming from
    # a ConfigMap
    - name: SPRING_CONFIG_LOCATION
      value: /config/application.properties
    # Pattern environment variable is picked up from a config map
    - name: PATTERN
      valueFrom:
        configMapKeyRef:
          name: random-generator-config
          key: PATTERN
    # Use 'envFrom' to pick up multiple enviroment variables from a config map
    envFrom:
    - configMapRef:
        name: random-generator-config
        optional: false
      prefix: CONFIG_
    volumeMounts:
    - name: config-volume
      mountPath: /config
    - name: secret-volume
      mountPath: /secret
  volumes:
  - name: secret-volume
    secret:
      secretName: my-secret
  - name: config-volume
    configMap:
      name: random-generator-config
  # Volume is mounted directly from a config map
