Multiple Containers in a Pod

How Pods manage multiple containers

Pods are designed to support multiple cooperating processes (as containers) that form a cohesive unit of service. The containers in a Pod are automatically co-located and co-scheduled on the same physical or virtual machine in the cluster. The containers can share resources and dependencies, communicate with one another, and coordinate when and how they are terminated.

In a pod, you may need two services to work together such as a web server and logging service that can scale up and down together. That is why you have multi-container pods that share the same lifecycle which means they are created and destroyed together. They share the same network space which means they can refer to each other as localhost and they have access to the same storage volumes. This way you do not have to establish volume sharing or services between the pods to enable communication between them

apiVersion: v1
kind: Pod
  name: multi-conatiner-pod
    type: multi-conatiner

    - name: nginx-container
      image: nginx
    - name: redis-container
      image: redis
$ kubectl create -f multi-conatiner-pod.yaml 
pod/multi-conatiner-pod created
$ kubectl get pods
NAME                  READY   STATUS    RESTARTS   AGE
multi-conatiner-pod   2/2     Running   0          41s

Leave a Reply

Your email address will not be published.