Bird
0
0

Which YAML snippet correctly configures this?

hard📝 Application Q8 of 15
Kubernetes - Secrets
You want to mount only the keys token and cert from a Secret named service-secret as files named access.token and certificate.pem respectively inside a pod volume at /etc/service. Which YAML snippet correctly configures this?
Avolumes: - name: service-secret-vol secret: secretName: service-secret containers: - name: app volumeMounts: - name: service-secret-vol mountPath: /etc/service subPath: token
Bvolumes: - name: service-secret-vol secret: secretName: service-secret items: - key: access.token path: token - key: certificate.pem path: cert containers: - name: app volumeMounts: - name: service-secret-vol mountPath: /etc/service
Cvolumes: - name: service-secret-vol secret: secretName: service-secret items: - key: token path: access.token - key: cert path: certificate.pem containers: - name: app volumeMounts: - name: service-secret-vol mountPath: /etc/service
Dvolumes: - name: service-secret-vol configMap: name: service-secret items: - key: token path: access.token - key: cert path: certificate.pem containers: - name: app volumeMounts: - name: service-secret-vol mountPath: /etc/service
Step-by-Step Solution
Solution:
  1. Step 1: Specify the secret volume

    The volume references the Secret service-secret and uses items to map keys to specific file paths.
  2. Step 2: Map keys to desired filenames

    Keys token and cert are mapped to access.token and certificate.pem respectively.
  3. Step 3: Mount the volume

    The container mounts the volume at /etc/service.
  4. Final Answer:

    volumes: - name: service-secret-vol secret: secretName: service-secret items: - key: token path: access.token - key: cert path: certificate.pem containers: - name: app volumeMounts: - name: service-secret-vol mountPath: /etc/service correctly implements the selective key mounting with custom filenames.
  5. Quick Check:

    Check items key-path mapping and volumeMount path. [OK]
Quick Trick: Use 'items' to map secret keys to custom file names [OK]
Common Mistakes:
  • Confusing key and path values
  • Using configMap instead of secret
  • Omitting 'items' to filter keys

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes