Can i configure Secrets and ConfigMap in the same deployment config?

pls check the below example, i tried and it doesn’t work, kindly advise the right configuration.

Issue: it applies either secret or configmap(first one), it doesn’t apply both to pod.

Ex:

spec:
  containers:
  - name: app-config
    image: kodekloud/webapp-color
    env:
      - name: Profile
        value: "dev"
    envFrom:
      - secretRef:
          name: vault-secret
    envFrom:
      - configMapRef:
          name: scg-config

You just need one “envFrom” - move configMapRef under same ‘envFrom’ as a secret one

spec:
  containers:
  - name: app-config
    image: kodekloud/webapp-color
    env:
      - name: Profile
        value: "dev"
    envFrom:
      - secretRef:
          name: vault-secret
      - configMapRef:
          name: scg-config

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#envfromsource-v1-core

2 Likes

@k8sGuy, Thank you so much for the quick resolution.