January 2019
Intermediate to advanced
484 pages
11h 48m
English
Pods in Kubernetes have their own real IP addresses. Containers within a pod share network namespace, so they see each other as localhost. This is implemented by the network container by default, which acts as a bridge to dispatch traffic for every container in a pod. Let's see how this works in the following example. Let's use the first example from Chapter 3, Getting Started with Kubernetes, which includes two containers, nginx and centos, inside one pod:
#cat 6-1-1_pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: example
spec:
containers:
- name: web
image: nginx
- name: centos
image: centos
command: ["/bin/sh", "-c", "while : ;do curl http://localhost:80/; sleep 10; done"]
// create the Pod #kubectl ...Read now
Unlock full access