Kubernetes Ephemeral Containers

Viewed 204

We are using the Python Docker SDK to create ephemeral containers in Kubernetes. My question is if these new containers will also share the same networking as the other containers in the pod? In other words, can this newly created ephemeral container access the original container that created it using localhost?

2 Answers

My question is if these new containers will also share the same networking as the other containers in the pod?

Yes. Although the specific nature of the ephemeral container networking is not documented per se. Essentially, an ephemeral container runs in a Pod and it's well described in the docs that the containers in a Pod share the IP address and the networking space.

✌️

To give a little bit more insight on Containers and Pods for future visitors:

My question is if these new containers will also share the same networking as the other containers in the pod?

Rightly said by @Rico - yes. Basically, when Kubernetes schedules a Pod to run on a Node, it creates a "network namespace" for the Pod in the node's Linux kernel. All Containers within the same Pod shares the same network namespace.

In other words, can this newly created ephemeral container access the original container that created it using localhost?

I think you can't rephrase your first question like this, they both are different questions. And answer to this question is NO - once a Container is destroyed, that Container (or any of its state) can't be accessed, and that's the whole point of being ephemeral. Also, you said "original container that created it" - it not the Container who creates another Container, it is the Kubernetes who creates new Container when old Container is crashed because of some reasons.

Related