Skip to content
Latchkey

What Is a Deployment in Kubernetes? Rolling Updates Explained

A Deployment is the Kubernetes object that keeps a chosen number of identical pods running and orchestrates safe rolling updates when their image changes.

You rarely manage pods by hand. Instead you declare a Deployment that says "run N replicas of this pod spec", and Kubernetes maintains it. When you change the image, the Deployment performs a controlled rollout - and can roll back if it goes wrong. It is the workhorse object for stateless apps.

What it manages

A Deployment owns a ReplicaSet, which owns the pods. You set replicas: 3 and a pod template; Kubernetes ensures three matching pods exist, recreating any that die.

Rolling updates

Change the image and the Deployment gradually replaces old pods with new ones - bringing up new pods, waiting for readiness, then retiring old ones. Settings like maxUnavailable and maxSurge control how aggressive the rollout is.

Rollbacks

Because the Deployment keeps revision history, kubectl rollout undo reverts to the previous working version if a new rollout misbehaves - a crucial safety net for CD.

A minimal spec

A Deployment YAML sets spec.replicas, a selector, and a template describing the pod (its containers and image). Applying it with kubectl apply -f deploy.yaml makes it real.

Deployments as the CD target

Continuous delivery usually updates the Deployment’s image to the digest CI just built and pushed. Kubernetes then handles the rollout. Readiness probes ensure traffic only reaches pods that are actually ready.

Key takeaways

  • A Deployment maintains N replica pods and handles rolling updates.
  • It keeps revision history, so rollbacks are a single command.
  • CD targets the Deployment by updating its image to the newly built one.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →