kubectl-scale
Scale the number of pod replicas
TLDR
Scale a replica set
Scale a resource identified by a file
Scale a deployment based on current number of replicas
SYNOPSIS
kubectl scale [--current-replicas=N] [--replicas=N] [--replicas-only] [--timeout=duration] (-f FILENAME | TYPE NAME | TYPE/NAME)
PARAMETERS
--current-replicas=N
Scale only if current replica count matches N; prevents accidental overwrites.
--replicas=N
Desired number of replicas (default 1); set to 0 to pause.
--replicas-only
Set replicas directly, bypassing Horizontal Pod Autoscaler calculations.
--timeout=duration
Time to wait for scaling completion (e.g., 30s, 5m); default 0s.
DESCRIPTION
kubectl scale is a powerful Kubernetes command-line tool used to dynamically adjust the number of pod replicas for resources like Deployments, ReplicaSets, ReplicationControllers, StatefulSets, and Jobs. It modifies the spec.replicas field in the target resource's specification, triggering Kubernetes to create or delete pods as needed to match the desired count. This enables rapid scaling of applications in response to varying workloads, such as traffic spikes or resource optimization.
The command supports scaling a single resource or multiple at once via files or selectors. For Deployments and ReplicaSets, scaling typically initiates a rolling update to minimize downtime. Scaling to zero (--replicas=0) terminates pods but retains the resource definition for easy rescaling later. It integrates with Horizontal Pod Autoscaler (HPA) but bypasses it when using --replicas-only.
Key benefits include simplicity for manual interventions, support for dry-run previews, and timeout controls for reliability in large clusters. It's essential for DevOps workflows, CI/CD pipelines, and blue-green deployments, ensuring applications remain resilient and cost-efficient.
CAVEATS
Scaling Jobs affects parallel pod count but not completions; use --replicas=0 cautiously as it stops but doesn't delete pods. Requires edit permissions on the resource.
EXAMPLES
kubectl scale deployment/nginx --replicas=3
kubectl scale --replicas=0 --filename=resources.yaml
kubectl scale statefulset/web --current-replicas=2 --replicas=5
RESOURCE TYPES
Supports: Deployment, ReplicaSet, ReplicationController, StatefulSet, Job. Use kubectl scale --help for latest.
HISTORY
Introduced in Kubernetes v1.0 (2014) as part of core scaling features; enhanced in v1.13+ with StatefulSet support and timeout options for better cluster management.
SEE ALSO
kubectl get(1), kubectl apply(1), kubectl autoscale(1), kubectl rollout(1)


