In this scenario, we would focus on the communications between containers within single Pod:
- Let's create two containers in one Pod: a nginx web application and a CentOS, which checks port 80 on localhost:
// configuration file of creating two containers within a pod$ cat two-container-pod.yamlapiVersion: v1kind: Podmetadata: name: two-containerspec: containers: - name: web image: nginx ports: - containerPort: 80 hostPort: 80 - name: centos image: centos command: ["/bin/sh", "-c", "while : ;do curl http://localhost:80/; sleep 30; done"]// create the pod$ kubectl create -f two-container-pod.yamlpod "two-container" created// check the status of the newly-created Pod$ kubectl get pod two-containerNAME READY ...