Bird
0
0

You want to mount a secret as a volume in a pod, but only expose the key db-password as a file named password.txt inside the container at /etc/db. Which volume configuration achieves this?

hard📝 Best Practice Q15 of 15
Kubernetes - Secrets
You want to mount a secret as a volume in a pod, but only expose the key db-password as a file named password.txt inside the container at /etc/db. Which volume configuration achieves this?
Avolumes: - name: db-secret secret: secretName: mysecret items: - key: db-password path: password.txt containers: - name: app volumeMounts: - name: db-secret mountPath: /etc/db
Bvolumes: - name: db-secret secret: secretName: mysecret items: - key: password.txt path: db-password containers: - name: app volumeMounts: - name: db-secret mountPath: /etc/db
Cvolumes: - name: db-secret secret: secretName: mysecret containers: - name: app volumeMounts: - name: db-secret mountPath: /etc/db/password.txt
Dvolumes: - name: db-secret configMap: name: mysecret items: - key: db-password path: password.txt containers: - name: app volumeMounts: - name: db-secret mountPath: /etc/db
Step-by-Step Solution
Solution:
  1. Step 1: Use secret volume with items to map keys to filenames

    The items field allows selecting specific keys and renaming files.
  2. Step 2: Verify correct key and path mapping

    Key db-password mapped to password.txt with mountPath /etc/db matches volumes: - name: db-secret secret: secretName: mysecret items: - key: db-password path: password.txt containers: - name: app volumeMounts: - name: db-secret mountPath: /etc/db.
  3. Final Answer:

    Correctly maps the secret key to the desired filename and mount path. -> Option A
  4. Quick Check:

    Use items to rename secret keys in volume [OK]
Quick Trick: Use items to rename secret keys as files [OK]
Common Mistakes:
  • Swapping key and path in items
  • Using configMap instead of secret
  • Mounting secret directly without items for renaming

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes