CKA · Question #25
Create a pod that having 3 containers in it? (Multi-Container)
This simulation task tests your ability to define and create a Kubernetes Pod with multiple containers (multi-container Pod) using either kubectl or a YAML manifest. The correct approach is to write a Pod spec with a containers list containing three container definitions.
Question
Explanation
This simulation task tests your ability to define and create a Kubernetes Pod with multiple containers (multi-container Pod) using either kubectl or a YAML manifest. The correct approach is to write a Pod spec with a containers list containing three container definitions.
Approach. In Kubernetes, a multi-container Pod is defined by specifying multiple entries under the spec.containers array in a Pod manifest. You would create a YAML file (e.g., multi-pod.yaml) with apiVersion: v1, kind: Pod, a metadata.name, and under spec.containers list three items each with a unique name and image field. Apply it with kubectl apply -f multi-pod.yaml (or kubectl create -f multi-pod.yaml). All containers in the Pod share the same network namespace and can communicate via localhost, and they share the Pod's lifecycle - they are scheduled together on the same node.
Concept tested. Kubernetes multi-container Pod definition - understanding the spec.containers array structure in a Pod manifest, where multiple containers are co-located, share network/storage, and are managed as a single scheduling unit.
Reference. https://kubernetes.io/docs/concepts/workloads/pods/#how-pods-manage-multiple-containers
Topics
Community Discussion
No community discussion yet for this question.