How to Scale a Kubernetes Deployment
If kubectl get pods returns nothing but the Deployment still exists, check the replica count - READY 0/0 means it was scaled to zero. Bring it back up with kubectl scale or by editing deployment.yaml and re-applying.
Why a Deployment can be "READY 0/0"
A Kubernetes Deployment is the desired-state description of your app. The
replicas field tells the scheduler how many pods to keep running. When someone
scales a Deployment to zero - to save resources, drain traffic, or pause a
rollout - every pod is terminated immediately. The Deployment object itself
stays; the app is just gone.
kubectl get pods # nothing listed
kubectl get deployment web # READY 0/0, AVAILABLE 0
kubectl describe deployment web # replicas: 0 in the spec
Option 1 - scale directly with kubectl
The fastest path is kubectl scale. No file editing needed:
kubectl scale deployment web --replicas=2
kubectl rollout status deployment/web # watch pods come up
This patches the replica count live. It works immediately, but the change is
not reflected in your manifest - the next kubectl apply from the old file
will put it back to zero.
Option 2 - edit the manifest and re-apply
The GitOps-safe approach: fix the source of truth (the YAML file), then apply it so the cluster and the file agree.
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 2 # was 0 - set to a sensible number
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: nginx:stable
Apply the fixed manifest:
kubectl apply -f deployment.yaml
kubectl rollout status deployment/web
Pods appear within seconds. kubectl get pods will show them moving through
ContainerCreating to Running.
Which approach to use
Use kubectl scale for an immediate incident fix. Then update your manifest
(or Helm values) so the file matches the live state - otherwise the next
deployment pipeline run silently scales back to zero.
In production, the bigger question is why it was zero in the first place. Check the audit log:
kubectl get events --sort-by=.lastTimestamp
Most shops lock down kubectl scale to specific service accounts and require
a pull request for replica count changes - so a scale-to-zero incident is
traceable to a commit or a pipeline step, not a mystery.
Want to try it hands-on? HeyDevJob gives you this exact setup in a live cloud workspace in your browser - edit it, run it, and see it work. Free, nothing to install.
Try it in a workspace →What you'll practice
- Using kubectl scale to bring a zero-replica Deployment back up
- Editing spec.replicas in a manifest and re-applying with kubectl apply
- Watching a rollout with kubectl rollout status
FAQ
How do I scale a Kubernetes Deployment back up?
Run kubectl scale deployment <name> --replicas=<n> for an immediate fix, or set spec.replicas in your YAML manifest and run kubectl apply -f deployment.yaml. Both bring pods back up within seconds.
Why does kubectl get pods show nothing when the Deployment exists?
The Deployment's replica count is zero. Zero replicas means the scheduler terminates all pods and creates no new ones. The Deployment object stays - only the pods are gone. Check with kubectl describe deployment <name>.
What is the difference between kubectl scale and kubectl apply for changing replicas?
kubectl scale patches the live replica count immediately but does not update any manifest file. kubectl apply reads the replicas field from your YAML and applies it - the GitOps-safe path that keeps file and cluster in sync.
Keep learning
Learn it by doing. Open this in a live cloud workspace, make the change yourself, and keep a record of the work you can share.
Open the workspace →