Reputation: 1045
Kubernetes documentation describes pod as a wrapper
around one or more containers. containers running inside
of a pod share a set of namespaces (e.g. network) which makes me think namespaces
are nested (I kind doubt that). What is the wrapper
here from container runtime's perspective?
Since containers are just processes constrained by namespaces, Cgroups
e.g. Perhaps, pod is just the first container
launched by Kubelet and the rest of containers are started and grouped by namespaces.
Upvotes: 14
Views: 15903
Reputation: 821
Pods are often confused with containers. And sometimes thought to be the same. I will try to clarify it using simple facts here:
Examples:
Deployment1: [
Pod1: [container-a, container-b],
]
Deployment2: [
Pod1: [container-x, container-y],
Pod2: [container-x-copy, container-y-copy],
Pod3: [container-x-copy, container-y-copy]
]
Upvotes: 0
Reputation: 21
Analogy : Think of pod as your apartment. Your apartment has different rooms for different stuff like kitchen for cooking, bedroom for sleep etc. These different rooms are containers within your pod (apartment) targeted to provide different services.
Naturally all rooms (containers) within your apartment (pod) will share the same network aka living space / walking space to go from one room to another.
That makes your apartment kind of wrapper for your rooms.
Upvotes: 2
Reputation: 6853
Pod is just a co-located group of container and an Kubernetes object.
Instead of deploying them separate you can do deploy a pod of containers
.
Best practices is that you should not actually run multiple processes via single container and here is the place where pod idea comes to a place. So with running pods you are grouping containers together and orchestrate them as single object.
Containers in a pod runs the same Network namespace (ip address and port space) so you have to be careful no to have the same port space used by two processes. This differs for example when it comes to filesystem, since the containers fs comes from the image fs. The file systems are isolated unless they will share one Volume.
Upvotes: 4
Reputation: 54211
The main difference is networking, the network namespace is shared by all containers in the same Pod. Optionally, the process (pid) namespace can also be shared. That means containers in the same Pod all see the same localhost
network (which is otherwise hidden from everything else, like normal for localhost) and optionally can send signals to processes in other containers.
The idea is the Pods are groups of related containers, not really a wrapper per se but a set of containers that should always deploy together for whatever reason. Usually that's a primary container and then some sidecars providing support services (mesh routing, log collection, etc).
Upvotes: 18