← Lessons

quiz vs the machine

Silver1100

System Design

Kubernetes Pods and Services

The smallest deployable unit in Kubernetes and how stable networking is provided.

4 min read · intro · beat Silver to climb

Pods

A pod is the smallest deployable unit in Kubernetes. It wraps one or more containers that share the same network address and storage volumes. Containers in a pod are always scheduled together on the same node.

Most pods hold a single application container, sometimes with a small helper sidecar alongside it.

The networking problem

Pods are ephemeral. They are created and destroyed as the system scales or heals, and each new pod gets a new IP address. Clients cannot rely on a pod IP staying the same.

Services

A Service gives a stable virtual address and DNS name for a set of pods. It uses label selectors to find matching pods and load balances traffic across them.

  • ClusterIP internal only address inside the cluster.
  • NodePort exposes a port on every node.
  • LoadBalancer provisions an external load balancer.

Because the Service tracks pods by label, replacing a pod does not break clients. The Service simply updates its endpoint list behind the scenes.

Key idea

Pods are ephemeral units of one or more containers, and a Service provides a stable address that load balances across the pods matching its selector.

Check yourself

Answer to earn rating on the learn ladder.

1. Why do clients connect through a Service instead of directly to pods?

2. How does a Service decide which pods to route to?