Kubernetes Autoscaling

Manual Scaling

Manual VPA

In this guide, you’ll learn how to use the Vertical Pod Autoscaler (VPA) to adjust CPU and memory for a simple Flask application running on Kubernetes. We’ll deploy a single-replica Deployment, observe pod initialization, and manually trigger a resource resize to see VPA in action.

Prerequisites

1. Deploy the Flask Application

Apply the Deployment and Service manifests:

kubectl apply -f deployment.yml
kubectl apply -f service.yml

Expected output:

deployment.apps/flask-web-app configured
service/flask-web-app-service unchanged
ResourcePurposeManifest
DeploymentRuns the Flask web applicationdeployment.yml
ServiceExposes the Flask applicationservice.yml

2. Observe Pod Initialization

Immediately list the pods to see the initialization phase:

kubectl get pods

Example output:

NAME                                  READY   STATUS     RESTARTS   AGE
flask-web-app-5d9dbb9d44-spjmk        0/1     Init:0/1   0          4s

The new pod will appear in Init:0/1 while it pulls the image and runs init containers.

3. Monitor the Pod Resize

After a moment, check the pods again:

kubectl get pods

Example output:

NAME                                  READY   STATUS        RESTARTS   AGE
flask-web-app-5d9dbb9d44-spjmk        1/1     Running       0          65s
flask-web-app-78689f449c-kq8xs        1/1     Terminating   0          3m13s

Here, VPA has created a new pod with updated (larger) resource requests and is terminating the old one.

Note

Manual updates to resource requests take effect immediately, but in production VPA performs these adjustments automatically based on real-time metrics.

4. How Vertical Pod Autoscaler Works

The Vertical Pod Autoscaler continuously monitors pod metrics and updates their requests and limits to match actual usage. In this exercise, updating the Deployment triggered a scale-up. In a production environment, VPA would automate these changes without manual intervention.

Warning

Manual resizing can cause brief downtime as pods restart. Always test resource changes in a staging environment before applying to production.

References

Watch Video

Watch video content

Practice Lab

Practice lab

Previous
Manual HPA