Bird
0
0

What is the recommended way to expose all keys from a Secret named config-secret as environment variables in a Pod without specifying each key individually?

hard📝 Application Q9 of 15
Kubernetes - Secrets
What is the recommended way to expose all keys from a Secret named config-secret as environment variables in a Pod without specifying each key individually?
AMount the Secret as a volume and read keys inside the container
BUse <code>envFrom:</code> with <code>secretRef:</code> pointing to <code>config-secret</code>
CList each key under <code>env:</code> with <code>secretKeyRef</code>
DConvert the Secret to a ConfigMap and use <code>envFrom:</code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand envFrom

    envFrom allows injecting all keys from a Secret as environment variables without listing each key.
  2. Step 2: Use secretRef with envFrom

    Specify envFrom.secretRef with the Secret name to inject all keys.
  3. Final Answer:

    Use envFrom with secretRef pointing to config-secret -> Option B
  4. Quick Check:

    envFrom.secretRef injects all Secret keys [OK]
Quick Trick: Use envFrom.secretRef to inject all Secret keys [OK]
Common Mistakes:
  • Mounting Secret as volume instead of env vars
  • Listing each key manually under env
  • Converting Secret to ConfigMap unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes