Manual Scaling
Manually increase or decrease the number of replicas managed by a scalable Kubernetes workload.
Key Topics
- • Deployment replicas
- • StatefulSet scaling
- • kubectl scale
- • Manual capacity control
Learn how to scale and manage Kubernetes applications using replicas, Horizontal Pod Autoscaler, Vertical Pod Autoscaler, node autoscaling, resource management, rolling updates, and operational tools.
Kubernetes Operations
Manual Scaling
Horizontal Pod Autoscaler
Vertical Pod Autoscaler
Node Autoscaling
Rolling Updates & Rollbacks
Introduction
Kubernetes helps automate deployment and management of containerized applications. After deploying an application, you need to manage capacity, resource usage, updates, failures, and changing traffic demands.
Scaling allows Kubernetes workloads to increase or decrease capacity. Management tools help operators update applications, inspect workload state, monitor resource usage, and recover from deployment problems.
Kubernetes supports manual and automatic scaling approaches, including horizontal scaling, vertical resource scaling, and node autoscaling depending on the workload and cluster configuration.
Scaling Methods
Kubernetes provides multiple approaches for adjusting workload capacity and cluster infrastructure.
Manually increase or decrease the number of replicas managed by a scalable Kubernetes workload.
Key Topics
Automatically adjusts the number of workload replicas based on observed metrics and configured targets.
Key Topics
Adjusts container resource requests and limits based on workload usage and resource recommendations.
Key Topics
Adjusts cluster node capacity to help provide infrastructure for workloads that cannot be scheduled on existing nodes.
Key Topics
Manual Scaling
Many Kubernetes workload resources support scaling. You can manually increase or decrease the number of replicas when you need more or less application capacity.
For example, a Deployment can be scaled using kubectl. Kubernetes then works to create or remove Pods until the desired number of replicas is reached.
Manual Scaling Example
kubectl scale deployment nginx --replicas=5 kubectl get deployment nginx
Horizontal Scaling
The HorizontalPodAutoscaler automatically adjusts the number of replicas for supported workload resources based on observed metrics and configured targets.
A common example is scaling a Deployment based on average CPU or memory utilization. The HPA can increase replicas when demand rises and reduce replicas when demand falls within its configured limits.
Resource requests are important when using utilization-based scaling because utilization is calculated relative to requested resources.
HPA Example
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: nginx-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: nginx
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 60Vertical Scaling
VerticalPodAutoscaler focuses on adjusting CPU and memory resource requests for workloads according to usage and recommendations.
VPA is implemented separately from the core HorizontalPodAutoscaler and requires installation in a cluster before it can be used.
Depending on its configuration and supported features, VPA can provide recommendations or apply updated resource settings to workloads.
VPA Example
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: nginx-vpa
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: nginx
updatePolicy:
updateMode: "Recreate"Cluster Capacity
Scaling Pods is not always enough. If workloads cannot be scheduled because the cluster does not have sufficient capacity, additional nodes may be required.
Node autoscaling can provision additional nodes when workloads need capacity and consolidate or remove unnecessary capacity when appropriate.
The specific node autoscaling implementation depends on the Kubernetes environment and infrastructure configuration.
Scaling Flow
Traffic Increases
│
▼
Horizontal Pod Autoscaler
│
▼
More Pod Replicas
│
▼
Insufficient Node Capacity?
│
▼
Node Autoscaler
│
▼
Additional Cluster NodesResource Management
Resource requests tell the Kubernetes scheduler how much CPU and memory a container requires. Resource limits define the maximum amount of certain resources that a container can use.
Proper resource configuration improves scheduling decisions and helps autoscaling systems make more meaningful decisions.
Resource Configuration
resources:
requests:
cpu: "250m"
memory: "256Mi"
limits:
cpu: "500m"
memory: "512Mi"Workload Management
Deployments and other workload controllers maintain the desired number of application replicas.
Deployments can gradually replace older application versions with newer versions.
Kubernetes workload management allows you to inspect and roll back supported Deployment revisions when necessary.
Resource requests help the scheduler determine suitable nodes for Pods.
CPU and memory limits define resource boundaries for containers.
Metrics and monitoring help operators understand workload health, utilization, and scaling requirements.
Application Updates
Kubernetes Deployments support controlled updates to application versions. A rolling update gradually replaces existing Pods with new Pods according to the Deployment strategy.
Deployment history can be inspected and supported revisions can be rolled back if a new application version causes problems.
Deployment Management
# Check rollout status kubectl rollout status deployment/nginx # View revision history kubectl rollout history deployment/nginx # Roll back kubectl rollout undo deployment/nginx
kubectl
Use kubectl to inspect workloads, adjust replica counts, monitor autoscalers, and manage application rollouts.
kubectl get deploymentsDisplay Deployments in the current namespace.
kubectl scale deployment nginx --replicas=5Manually scale a Deployment to five replicas.
kubectl get hpaDisplay HorizontalPodAutoscaler resources.
kubectl top podsDisplay available pod resource metrics.
kubectl rollout status deployment/nginxWatch the rollout status of a Deployment.
kubectl rollout history deployment/nginxView Deployment revision history.
kubectl rollout undo deployment/nginxRoll back a Deployment to a previous revision.
kubectl get nodesDisplay Kubernetes cluster nodes.
Learning Roadmap
Follow these steps to understand how Kubernetes manages workload capacity and cluster resources.
Learn how Kubernetes workload controllers maintain the desired number of application instances.
Scale Deployments and StatefulSets manually to understand how replica counts affect application capacity.
Define CPU and memory requests so Kubernetes can schedule workloads and calculate utilization correctly.
Use the HorizontalPodAutoscaler to adjust replica counts based on observed metrics.
Understand how VerticalPodAutoscaler can recommend or manage resource requests for workloads.
Learn how node autoscaling and cluster capacity management support workloads as demand changes.
Best Practices
Set realistic CPU and memory requests to help Kubernetes schedule workloads and support utilization-based autoscaling.
Configure sensible minimum and maximum replica counts to prevent unexpected scaling behavior.
Use resource metrics and application monitoring to understand real workload demand before adjusting scaling policies.
When an HPA manages a workload, avoid repeatedly applying conflicting replica values from other automation.
Test rollout and rollback procedures so application recovery processes are understood before production incidents.
Ensure node capacity and autoscaling infrastructure can support workloads when replica counts increase.
Continue Learning
Learn Kubernetes architecture, clusters, nodes, Pods, Deployments, Services, and kubectl fundamentals.
💾Learn Kubernetes volumes, PersistentVolumes, PersistentVolumeClaims, and StorageClasses.
🌐Learn Kubernetes Services, networking, DNS, external traffic, and Network Policies.
Next Step
Deploy an application, configure resource requests, manually change replica counts, and experiment with Horizontal Pod Autoscaling to understand how Kubernetes responds to changing workload demand.