Bird
0
0

You want to add a logging container to your Pod that shares the same volume with the main app container. Which configuration is correct to achieve this?

hard📝 Best Practice Q15 of 15
Kubernetes - Pods
You want to add a logging container to your Pod that shares the same volume with the main app container. Which configuration is correct to achieve this?
AMount the volume only in the logging container
BCreate separate volumes for each container and do not mount them
CDefine a shared volume under 'volumes' in Pod spec and mount it in both containers under 'volumeMounts'
DUse different Pods for logging and app containers without shared volumes
Step-by-Step Solution
Solution:
  1. Step 1: Understand volume sharing in Pods

    Volumes defined at Pod level can be mounted by multiple containers to share data.
  2. Step 2: Check options for volume usage

    Define a shared volume under 'volumes' in Pod spec and mount it in both containers under 'volumeMounts' correctly defines a shared volume and mounts it in both containers. Other options either separate volumes or do not mount properly, preventing sharing.
  3. Final Answer:

    Define a shared volume under 'volumes' in Pod spec and mount it in both containers under 'volumeMounts' -> Option C
  4. Quick Check:

    Shared volumes require Pod-level volume and mounts in containers [OK]
Quick Trick: Share volumes by defining once and mounting in all containers [OK]
Common Mistakes:
  • Defining separate volumes for each container
  • Not mounting volumes in all containers needing access
  • Using separate Pods instead of multi-container Pod

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes