scale
Scaling Kubernetes Resources
Set a new size for a Deployment, ReplicaSet, Replication Controller, or StatefulSet.
Scale also allows users to specify one or more preconditions for the scale action.
If –current-replicas or –resource-version is specified, it is validated before the scale is attempted, and it is guaranteed that the precondition holds true when the scale is sent to the server.
Command
$ kubectl scale [--resource-version=version] [--current-replicas=count] --replicas=COUNT (-f FILENAME | TYPE NAME) Example
Current State
$ kubectl get deployments NAME READY UP-TO-DATE AVAILABLE AGE nginx 1/1 1 1 24s Command
$ kubectl scale --replicas=3 deployment/nginx deployment.apps/nginx scaled New State
$ kubectl get deployments NAME READY UP-TO-DATE AVAILABLE AGE nginx 3/3 3 3 87s More Examples
# Scale a replicaset named 'foo' to 3. kubectl scale --replicas=3 rs/foo # Scale a resource identified by type and name specified in "foo.yaml" to 3. kubectl scale --replicas=3 -f foo.yaml # If the deployment named mysql's current size is 2, scale mysql to 3. kubectl scale --current-replicas=2 --replicas=3 deployment/mysql # Scale multiple replication controllers. kubectl scale --replicas=5 rc/foo rc/bar rc/baz # Scale statefulset named 'web' to 3. kubectl scale --replicas=3 statefulset/web Conditional Scale Update
It is possible to conditionally update the replicas if and only if the replicas haven’t changed from their last known value using the--current-replicas flag. e.g. kubectl scale --current-replicas=2 --replicas=3 deployment/mysql Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
Last modified December 22, 2023: Correct typo from 'Kubenetes' to 'Kubernetes' (11f82c1)