What Is a Kubernetes Deployment? Pod Replicas, Rolling Updates, and Rollbacks
A Kubernetes Deployment declares the desired number and configuration of application Pods and manages the system toward that state.
A Kubernetes Deployment declares the desired number and configuration of application Pods and manages the system toward that state. It creates ReplicaSets to maintain the Pod count; when the Pod template changes, it creates a new ReplicaSet and gradually replaces the old version. A Deployment is therefore more than a command to create Pods: it coordinates replica maintenance, updates, status checks, and a return to an earlier Pod template. It is usually a good fit for applications whose replicas can be replaced and do not need stable Pod identities or storage tied to each individual Pod.
How are a Deployment, ReplicaSet, and Pod connected?
A Pod is the unit that runs containers. A ReplicaSet keeps a specified number of matching Pods running. A Deployment manages ReplicaSets above that layer so it can create a new version and coordinate old and new replicas. For ordinary application releases, declare the Pod template and replica count in the Deployment instead of managing its ReplicaSets directly. Kubernetes recommends Deployments over direct ReplicaSet management unless you need custom update orchestration or no updates at all. Deployment documentation, ReplicaSet documentation
Declared Deployment
│ desired Pod template and replica count
▼
Deployment controller
│ creates, scales, and reduces ReplicaSets by version
├───────────────┐
▼ ▼
New ReplicaSet Previous ReplicaSet
│ │
New Pods Existing PodsThe controller does not send a one-time command and stop. It repeatedly compares the declared goal with the observed state and reduces the difference. For example, if replicas: 3, a ReplicaSet tries to restore three Pods after a Pod is deleted or fails. You can also change the count with kubectl scale, but if a manifest or Git repository is the source of truth, update spec.replicas there too; otherwise a later apply may restore the old count.
Write a first Deployment manifest
This example manages three NGINX Pods. The image reference is a placeholder; replace it before applying the manifest with an approved tag or digest from a registry you can access. The selector chooses which Pods the ReplicaSet manages, and it must match the labels in the Pod template.
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
labels:
app: web
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: registry.example.com/team/web:<approved-tag-or-digest>
ports:
- name: http
containerPort: 8080The selector and Pod-template labels must match from the start. In apps/v1, a Deployment selector cannot be changed after creation. Controllers with overlapping selectors can compete over the same Pods, so use a clear, unique selector for each workload. Deployment selector and strategy
The manifest declares that three equivalent Pods should exist. The Deployment itself does not run the containers or provide a stable network address to users. A separate Service is usually needed to send in-cluster traffic to a set of Pods. Service and Deployment are distinct resources: a Service provides a stable way to reach selected Pods even when Pod IPs change. Service documentation
How does an update proceed?
When a field in the Pod template changes—such as the image, environment, container port, or probe—the Deployment creates a new ReplicaSet and replaces Pods according to its strategy. A change to the Pod template starts a rollout; simply changing the replica count is not a new application version. If you edit the template again during a rollout, Kubernetes may adjust toward the latest template before finishing the earlier change, so watch which rollout revision is active.
The default strategy is RollingUpdate. It gradually adds ready new Pods and removes old ones. maxSurge limits how many Pods may be created above the desired count during an update; maxUnavailable limits how many may be unavailable. Each can be a whole number or percentage. Both default to 25%; percentage values are rounded up for maxSurge and down for maxUnavailable. They cannot both be zero. Rolling update strategy
For three replicas with the defaults, 25% surge rounds up to one and 25% unavailable rounds down to zero. With enough capacity, the Deployment can create one extra new Pod, wait for it to become available, and then reduce an old Pod while keeping all three available. This does not automatically guarantee zero downtime: the new Pod can fail to become ready or the cluster may lack spare capacity. A misconfigured readiness check can also route requests to an application before it is ready.
The Recreate strategy terminates the old Pods before creating the new ones, so there can be a period with no available replicas. It is simpler, but can cause downtime. RollingUpdate replaces Pods gradually, but may need spare capacity and requires the application to tolerate old and new versions running at the same time. Choose based on downtime tolerance, available CPU and memory, and compatibility between app versions and their data or protocols.
Apply and verify a rollout
The commands below show a read/write workflow for a new Deployment or changed Pod template. They were not run in this environment. Check the context and namespace first; substitute your manifest path and namespace.
kubectl config current-context
kubectl apply -n <namespace> -f <deployment-manifest.yaml>
kubectl rollout status -n <namespace> deployment/web --timeout=5m
kubectl get deployment,replicaset,pods -n <namespace> -l app=web
kubectl describe deployment/web -n <namespace>When kubectl rollout status succeeds, the rollout is complete. In kubectl get deployment, READY shows ready replicas against the desired count, UP-TO-DATE counts replicas using the new Pod template, and AVAILABLE counts replicas considered available. Compare these numbers with your target and inspect Pods and events. A successful apply response alone does not prove that the application is serving correctly.
If the application takes time to initialize, define an application-specific readinessProbe in the Pod template. Kubernetes can exclude a Pod that fails readiness from a Service's available endpoints. The path, port, and startup timing must match the application: an inaccurate probe may either pass an unready app or keep a healthy one marked unready. Readiness probes
What should you check when a rollout stalls?
If Pods in the new ReplicaSet show ImagePullBackOff, CrashLoopBackOff, or Pending, investigate the Pod itself as well as the Deployment events.
Run `kubectl describe deployment/web -n <namespace>` and check the selector, desired/updated/available replica counts, rollout conditions, and recent events.
Use `kubectl get pods -n <namespace> -l app=web -o wide` and `kubectl describe pod <pod> -n <namespace>` to see whether a new Pod was scheduled and whether the issue involves image access, permissions, mounts, or probes.
For a container that fails to start, compare `kubectl logs <pod> -n <namespace> -c web` with the previous container's logs using `--previous`. Check the exit code, configuration, actual image reference, Secrets and ConfigMaps, and resource requests and limits.
`ProgressDeadlineExceeded` means the Deployment did not make enough progress before its deadline. It does not mean Kubernetes automatically rolled back. Fix the cause and continue with the template, or decide whether to return to a stable revision.
Use kubectl rollout history deployment/web -n <namespace> to list stored revisions and add --revision=<number> to inspect one. After checking the target, run kubectl rollout undo deployment/web -n <namespace> --to-revision=<number> to restore an earlier template, then verify the rollout again. rollout history · rollout undo · rollout status
A rollback changes the Deployment's Pod template. It does not undo database schema changes, external data, or side effects that already happened. Confirm that the previous image is still available as well. Treat this as an operational limitation of template rollback: application data and infrastructure state need their own recovery plan.
Why not manage the ReplicaSet directly?
A ReplicaSet maintains Pod count, while the Deployment coordinates release versions and prior revisions. Manually scaling or editing a ReplicaSet owned by a Deployment can conflict with the declared state or be reversed by the controller. Manage replicas and the Pod template through the Deployment; use ReplicaSets to inspect rollout state and earlier versions.
Key points
A Deployment uses ReplicaSets to maintain the declared Pod template and replica count, and by default replaces versions with a RollingUpdate. A Deployment object alone does not make a release safe. The selector must be correct, new Pods must become ready, and the cluster needs the resources for any surge. Verify the apply, rollout status, Deployment and Pod events, and application readiness together. A rollback does not restore external data or state.
Sources
[Deployments](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/)
[ReplicaSet](https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/)
[Services](https://kubernetes.io/docs/concepts/services-networking/service/)
[Liveness, Readiness, and Startup Probes](https://kubernetes.io/docs/concepts/workloads/pods/probes/)
[kubectl rollout status](https://kubernetes.io/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_status/)
[kubectl rollout history](https://kubernetes.io/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_history/)
[kubectl rollout undo](https://kubernetes.io/docs/reference/kubectl/generated/kubectl_rollout/kubectl_rollout_undo/)
Scope: application Pod replication, the Deployment/ReplicaSet relationship, default rollout strategy, verification and rollback, and common stalled-rollout diagnosis. Official Kubernetes documentation was checked on 2026-11-22. The manifest and commands are explanatory examples and were not run against a cluster. Stable Pod identity for StatefulSets, HPA, and canary or blue-green operations are separate topics.