What is a Kubernetes Deployment?
· Category: Kubernetes
Short answer
A Kubernetes Deployment is a controller that manages a set of identical Pods. It ensures the desired number of replicas are running, supports rolling updates, and enables rollback to previous versions.
How it works
The Deployment controller maintains a ReplicaSet to manage Pods. When you update the Deployment, it creates a new ReplicaSet with the updated Pod template and gradually scales it up while scaling the old one down. If something goes wrong, you can roll back to a previous revision.
Example
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: nginx
image: nginx:1.25
ports:
- containerPort: 80
Why it matters
Deployments provide declarative updates for stateless applications. They automate scaling, self-healing, and zero-downtime updates, forming the backbone of most Kubernetes workloads.
Common issues
- Updating only the container tag may not trigger a rollout if the image pull policy is IfNotPresent.
- Resource limits should be set to prevent runaway Pods.
- Rollbacks do not restore deleted ConfigMaps or Secrets.