It's the default way to run any stateless service on Kubernetes.
A Deployment declares a pod template and a replica count. It doesn't manage pods directly: it creates a ReplicaSet for each version of the template, and the ReplicaSet keeps exactly replicas matching pods alive.
The chain is Deployment, then ReplicaSet (named web-<hash>), then Pods (web-<hash>-<random>). The hash comes from the pod template, so changing the template (image, env, resources) creates a new ReplicaSet; changing only replicas doesn't.
Rules of the spec:
spec.selector.matchLabelsmust matchspec.template.metadata.labels, and the selector is immutable after creation.spec.templateis a full pod spec withoutapiVersion/kind.
Scale with kubectl scale deploy web --replicas=5 or by editing replicas and re-applying. Prefer the file, otherwise the next apply undoes the manual scale (unless an autoscaler owns replicas, in which case leave it out of your manifest).
Deployments are for stateless, interchangeable pods: any replica can serve any request and can be killed at any time. For stable identities and per-replica storage use a StatefulSet; for one pod per node use a DaemonSet; for run-to-completion work use a Job.
kubectl get deploy shows READY (ready/desired), UP-TO-DATE and AVAILABLE replicas.
Example
kubectl create deployment web --image=nginx:1.27 --replicas=3
kubectl get deploy,rs,pods -l app=web
# deployment.apps/web 3/3 3 3
# replicaset.apps/web-5d8f7b9c4 3 3 3
# pod/web-5d8f7b9c4-4jx2l 1/1 Running ...
kubectl scale deploy web --replicas=5 # same ReplicaSet, 2 more pods
kubectl set image deploy/web nginx=nginx:1.28 # new template: new ReplicaSet
kubectl get rs -l app=web
# web-5d8f7b9c4 0 0 0 (old, kept for rollback)
# web-7c6d9f8b5 5 5 5Remember
- Deployment manages ReplicaSets; ReplicaSets manage pods
- Template change = new ReplicaSet; replica change = same one
- Use Deployments for stateless, interchangeable pods
Watch out for
- Selector labels that don't match the template labels: the API rejects the Deployment.