← 返回命令列表

Linux command

kubectl-scale 命令

趣味

复制后可按需替换文件名、目录或参数。

常用示例

Scale deployment replicas

kubectl scale deployment [name] --replicas=[3]

Scale multiple deployments

kubectl scale deployment [name1] [name2] --replicas=[3]

Scale with current replica check

kubectl scale deployment [name] --current-replicas=[2] --replicas=[3]

Scale from file

kubectl scale -f [manifest.yaml] --replicas=[5]

说明

kubectl scale adjusts the replica count for deployments, replica sets, replication controllers, and stateful sets, allowing you to increase or decrease the number of running pod instances on demand. Changes take effect immediately, with the Kubernetes controller manager working to reconcile the actual state to the desired replica count. The command supports a precondition flag (--current-replicas) that causes the scaling operation to fail if the current number of replicas does not match the expected value, which is useful for preventing race conditions in automated workflows. You can also scale resources defined in manifest files and apply the operation to multiple resources in a single invocation.

参数

--replicas _count_
Target number of replicas.
--current-replicas _count_
Precondition for current replicas.
-f, --filename _file_
Resource file to scale.
--timeout _duration_
Timeout for scaling operation.

FAQ

What is the kubectl-scale command used for?

kubectl scale adjusts the replica count for deployments, replica sets, replication controllers, and stateful sets, allowing you to increase or decrease the number of running pod instances on demand. Changes take effect immediately, with the Kubernetes controller manager working to reconcile the actual state to the desired replica count. The command supports a precondition flag (--current-replicas) that causes the scaling operation to fail if the current number of replicas does not match the expected value, which is useful for preventing race conditions in automated workflows. You can also scale resources defined in manifest files and apply the operation to multiple resources in a single invocation.

How do I run a basic kubectl-scale example?

Run `kubectl scale deployment [name] --replicas=[3]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --replicas _count_ do in kubectl-scale?

Target number of replicas.