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.