A Kubernetes Deployment is the standard object for running a stateless application in a cluster. You declare the desired state, such as the container image and the number of replicas, and the Deployment controller creates and maintains the Pods to match it. It also handles rolling updates, rollbacks, scaling and self-healing.
You rarely create Pods directly. A bare Pod is not replaced if its node fails, while a Deployment replaces it and manages versions through ReplicaSets.
A Deployment owns one or more ReplicaSets, and each ReplicaSet owns the Pods for one version of your Pod template.
Old ReplicaSets are kept, scaled to zero, up to revisionHistoryLimit (10 by default), which is what makes rollbacks possible.
Use a Deployment for stateless services such as web servers and APIs. Use a StatefulSet for workloads that need stable identity and storage, a DaemonSet for one Pod per node, and a Job or CronJob for finite tasks.
This manifest runs three replicas of a web app, with probes and resource settings that production clusters expect.
Key points:
selector.matchLabels must match the labels in template.metadata.labels. The selector is immutable after creation in apps/v1.apps/v1 API is the current one. The older extensions/v1beta1 and apps/v1beta1 versions were removed years ago.latest makes rollouts and rollbacks unpredictable.Apply and inspect it:
The default strategy is RollingUpdate. With maxSurge: 1 and maxUnavailable: 0, Kubernetes starts one extra Pod with the new version, waits until its readiness probe passes, then removes an old Pod, so capacity never drops below three.
Trigger an update by changing the image, and watch it finish:
If the new version misbehaves, review history and roll back:
The other strategy is Recreate, which stops all old Pods before starting new ones. It causes downtime and suits applications that cannot run two versions side by side. Blue-green and canary releases are not built-in strategies, and teams add them with tools such as Argo Rollouts, Flagger or a service mesh.
Readiness probes are what make a rolling update safe. Without one, Kubernetes treats a Pod as ready as soon as the container starts, and traffic can reach a Pod that is still booting.
Scale manually with one command:
For automatic scaling, attach a HorizontalPodAutoscaler that adjusts replicas from CPU, memory or custom metrics:
Autoscaling on CPU needs requests.cpu set on the container, and the cluster needs a metrics server.
Self-healing comes from the controllers. If a Pod crashes, the kubelet restarts the container. If a node dies or a Pod is deleted, the ReplicaSet creates a replacement elsewhere. If a liveness probe fails, the container is restarted, and while a readiness probe fails the Pod is removed from Service endpoints.
A Deployment does not give you a stable address, because Pods come and go with changing IPs. Put a Service in front of it, selecting the same label:
Expose it outside the cluster with an Ingress or the Gateway API, or with a Service of type LoadBalancer.
| Command | Purpose |
|---|---|
kubectl rollout pause deployment/my-app | Pause a rollout to batch several edits |
kubectl rollout restart deployment/my-app | Restart all Pods with a fresh rollout |
kubectl describe deployment my-app | See events and conditions |
kubectl get rs -l app=my-app | List the ReplicaSets and their revisions |
kubectl logs deployment/my-app | Read logs from one Pod of the Deployment |
If a rollout hangs, kubectl describe usually shows why: an image pull error, a failing readiness probe, or insufficient cluster resources. After progressDeadlineSeconds (600 seconds by default) the Deployment is marked as failed to progress, and it does not roll back by itself.
A Pod is a single running unit and is not replaced when its node fails. A Deployment manages many identical Pods through ReplicaSets, and replaces, scales and updates them.
A ReplicaSet only keeps a fixed number of Pods running. A Deployment adds versioned rollouts and rollbacks, and creates the ReplicaSets for you.
Use a Deployment for stateless apps. Use a StatefulSet when each replica needs a stable name or its own persistent volume, as with databases.
No. A failed rollout stalls and reports the condition, and you run kubectl rollout undo or let a tool such as Argo Rollouts do it.
A Kubernetes Deployment declares the desired state of a stateless application and keeps the cluster matching it. It provides replica management, zero-downtime rolling updates with readiness probes, quick rollbacks, scaling and self-healing. Pair it with a Service, pin image tags, and set resource requests and probes.