Two containers in one Pod must exchange intermediate files quickly during a request. What is the most direct built-in approach?
Select an answer to reveal the explanation.
Short Explanation
Containers in one Pod already share the apartment. Drop a shared emptyDir “kitchen counter” between them and pass files across—no separate Pods or public downloads required.
Full Explanation
When two containers in one Pod must exchange intermediate files quickly during a request, the most direct built-in approach is to mount a shared volume such as emptyDir into both containers at agreed paths. Both processes see the same scratch files without leaving the Pod, which suits municipal request pipelines that stage temporary artifacts between an application container and a helper.
Scheduling the containers on different nodes and sharing a hostPath to /tmp abandons the same-Pod design and couples behavior to node layout. Giving each container its own Pod and racing on a ReadWriteOnce PVC adds attach semantics and scheduling constraints unsuitable as the first design for intra-request scratch. Publishing files through a public Ingress so both containers download them exposes internal artifacts and adds needless latency and risk.
Exam caveat: emptyDir lasts only for the Pod lifetime and disappears on reschedule; it is not a backup system. For durable exchange use a PVC; for Pod-local scratch prefer emptyDir, optionally with medium: Memory for tmpfs-backed caches.
Operational check: apply a Pod with two containers mounting the same emptyDir; kubectl exec -c producer -- sh -c 'echo hi >/work/f'; kubectl exec -c consumer -- cat /work/f; delete the Pod and confirm the scratch data is gone.