A pod named 'web-app' is running but has no environment variables. The developer wants to inject a variable 'DB_URL=postgres://db:5432' from a ConfigMap named 'db-config'. Which pod spec snippet correctly achieves this?
Trap 1: env: - name: DB_URL value: "postgres://db:5432"
This sets a literal value, not from ConfigMap.
Trap 2: envFrom: - configMapRef: name: db-config key: DB_URL
envFrom imports all keys, not a specific one; syntax also wrong.
Trap 3: env: - name: DB_URL valueFrom: secretKeyRef: name:…
secretKeyRef is for Secrets, not ConfigMaps.
- A
env: - name: DB_URL value: "postgres://db:5432"
Why wrong: This sets a literal value, not from ConfigMap.
- B
envFrom: - configMapRef: name: db-config key: DB_URL
Why wrong: envFrom imports all keys, not a specific one; syntax also wrong.
- C
env: - name: DB_URL valueFrom: secretKeyRef: name: db-config key: DB_URL
Why wrong: secretKeyRef is for Secrets, not ConfigMaps.
- D
env: - name: DB_URL valueFrom: configMapKeyRef: name: db-config key: DB_URL
Correctly references ConfigMap key.