Bird
0
0

You want to mount only specific keys from a ConfigMap named app-config as files inside a container at /etc/config. Which volume configuration snippet achieves this?

hard📝 Best Practice Q15 of 15
Kubernetes - ConfigMaps
You want to mount only specific keys from a ConfigMap named app-config as files inside a container at /etc/config. Which volume configuration snippet achieves this?
Avolumes: - name: config-volume configMap: name: app-config exclude: - unused_key
Bvolumes: - name: config-volume configMap: name: app-config items: - key: database_url path: db_url - key: log_level path: log_level
Cvolumes: - name: config-volume secret: name: app-config items: - key: database_url path: db_url
Dvolumes: - name: config-volume configMap: name: app-config keys: - database_url - log_level
Step-by-Step Solution
Solution:
  1. Step 1: Understand selective key mounting

    Kubernetes allows selecting specific keys from a ConfigMap using the items field with key and path.
  2. Step 2: Identify correct syntax

    volumes: - name: config-volume configMap: name: app-config items: - key: database_url path: db_url - key: log_level path: log_level correctly uses items with key-path pairs to mount only chosen keys as files.
  3. Final Answer:

    volumes: - name: config-volume configMap: name: app-config items: - key: database_url path: db_url - key: log_level path: log_level -> Option B
  4. Quick Check:

    Use items with key and path to select keys [OK]
Quick Trick: Use 'items' with key and path to mount specific keys [OK]
Common Mistakes:
  • Using 'keys' instead of 'items' for selection
  • Confusing ConfigMap with Secret for this purpose
  • Trying to exclude keys instead of selecting them

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes