close
close

Explaining Pods in Kubernetes – DEV Community

The purpose of this pageđź“ť is to explain the concept of a pod in k8s from the five angles that I find useful. A bit of context relating pods to containers and VMs, and the three essentials of a pod: shared execution environment, unit of scale, and its ephemeral nature.

First/historically, the units of infrastructure planning are mainly in VM, Docker and Kubernetes (k8s).

  • A VM environment is a virtual machine
  • In the Docker environment, this is the container
  • In Kubernetes it’s a pod

Yes – k8s run on orchestrated containers. But containers should always run within Pods

What distinguishes pods from containers

My acronym is ALP.CC
1. annotation
2. labels (ideal for service object pods and IP management)
3. policy
4. limitations (resource)
5. co-planning

Essence #1: Shared execution environment

Pod is execution environment == collection of things an app needs to run**

Pod is

  • a thin pack of k8s insists that all containers are used
  • shared execution environment
  • IP address
  • Port
  • F.S
  • Memory

Each pod is an execution environment

Containers running within it share that environment: IP is shared between containers.

In the pods, when they need to talk to each other: the pod hosting interface

If you have a use case where >1 container needs to share resources, they will be in single pods. This is for specialist applications.

If not, create a loose connection with container-per-pod and then connect them over the network

Essence #2: Unity of scale/reproduction

The unit of scale is the pod: you add/remove pods. You don’t scale by adding containers to existing pods. Scale up – add pods, scale down – remove pods.

Multi-container pods – service mesh, where additional containers are injected into the pod to get improved services. Free container that increases the app container.

The deployment of pods is an atomic operation: all or nothing. Pod only appears when all containers are active.

All containers are always scheduled on the same node.

There is a higher level controller called Replica Set, wrapped in another higher level controller called Deployment.

Once you introduce horizontal scaling, it is more appropriate to talk about the reproductions of pods as replicas. The terms are closely related, but not identical.

Essence #3: Mortality. Pods are mortal, pods are livestock.

Born, live, die. that’s it. No magical return to life. Self-healing is misleading. A dead pod is not solved. It has been recreated.

Pods are deployed via the deployer – if pods don’t deliver anything of value. Why not just containers?

However, that doesn’t mean they can’t be restarted. On the contrary, I often encounter a “pod restart loop” situation during my support time.