lifecycle

kubectl scale

Sets a new desired replica count for a Deployment, StatefulSet, ReplicaSet, or ReplicationController. Optional preconditions guard against racing with another controller.

kubectl scale [--resource-version=VERSION] [--current-replicas=COUNT] --replicas=COUNT TYPE/NAME

Common flags

Flag Purpose
--replicas Target replica count (required).
--current-replicas Precondition: only scale if the current count matches.
--resource-version Precondition: only scale if the resourceVersion matches.
-f, --filename Scale the resource(s) referenced in a file.
--timeout How long to wait for the scale action to be accepted.

Examples

kubectl scale deploy/web --replicas=5

Scale to 5 replicas.

kubectl scale statefulset/db --replicas=0

Drain a StatefulSet to zero for maintenance.

kubectl scale --current-replicas=3 --replicas=6 deploy/web

Scale only if current count is 3 (safety guard).

Gotcha

scale is one-shot and imperative - an HPA can immediately reset your value. For persistent changes, edit the manifest instead.

Related commands

← All kubectl commands · Docker vs Kubernetes