Bird
0
0

Given this Pod spec snippet, what will be the value of environment variable API_KEY inside the container?

medium📝 Command Output Q4 of 15
Kubernetes - Secrets
Given this Pod spec snippet, what will be the value of environment variable API_KEY inside the container?
env:
- name: API_KEY
  valueFrom:
    secretKeyRef:
      name: api-secret
      key: key1

Assuming the Secret api-secret has key1: abc123.
Aapi-secret
Babc123
Ckey1
Dnull
Step-by-Step Solution
Solution:
  1. Step 1: Understand Secret key reference

    The env var API_KEY gets value from Secret api-secret key key1.
  2. Step 2: Check Secret data

    The Secret's key1 value is abc123, so API_KEY will be abc123.
  3. Final Answer:

    abc123 -> Option B
  4. Quick Check:

    Secret key value = API_KEY value = abc123 [OK]
Quick Trick: Secret key value becomes env var value [OK]
Common Mistakes:
  • Using Secret name as value
  • Using key name as value
  • Assuming null if key exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes