Deployments

Learn about Deployments in Kubernetes.

We'll cover the following

Even though Kubernetes works with Pods, you’ll almost always deploy them via higher-level controllers such as Deployments, StatefulSets, and DaemonSets. These all run on the control plane and operate as background watch loops, reconciling observed state with desired state.

Deployments add self-healing, scaling, rolling updates, and versioned rollbacks to stateless apps.

Service objects and stable networking

Earlier in the chapter, we said that Pods are mortal and can die. However, if they’re managed by a controller, they get replaced by new Pods with new IDs and new IP addresses. The same thing happens with rollouts and scaling operations:

  • Rollouts replace old Pods with new ones with new IPs

  • Scaling up adds new Pods with new IPs

  • Scaling down deletes existing Pods.

Events like these generate IP churn and make Pods unreliable. For example, clients cannot make reliable connections to individual Pods as the Pods are not guaranteed to be there.

This is where Kubernetes Services come into play by providing reliable networking for groups of Pods.

The following figure shows internal and external clients connecting to a group of Pods via a Kubernetes Service. The Service (capital “S” because it’s a Kubernetes API object) provides a reliable name and IP and load balances requests to the Pods behind it.

Get hands-on with 1400+ tech skills courses.