Vertical Pod Autoscaler (VPA)
1. Introduction to VPA
1.1. What is VPA
VPA is a tool that automatically adjusts vertical resources (CPU and memory) in a container. VPA adjusts Pod’s resource requests based on the actual use of resources in the container, ensuring that the Pod has enough resources during runtime.
1.2. Advantages of VPA
Advantages
- Resource Optimization: VPA improves resource utilization by dynamically adjusting container resource requests.
- Performance Improvement: VPA enhances application performance and stability by ensuring Pods have enough resources.
- Automation: VPA can automatically adjust resources without human intervention.
1.2.1. Limitations of VPA
-
Since VPA automatically adjusts the resource requests of Pods, Pods may be restarted in the background and may be scheduled to other nodes.
-
Avoid using
VPAandHPAsimultaneously.
2. Installation
2.1. Prerequisites
- Kubernetes 1.10+
2.2. Deployment
2.2.1. Deploy VPA service certificate
curl -sfL https://docs.surfercloud.com/uk8s/yaml/vpa/gencerts.sh | sh -2.3. Deploy VPA service
For 1.22 and later versions
kubectl apply -f https://docs.surfercloud.com/uk8s/yaml/vpa/vpa.yamlFor versions below 1.22
kubectl apply -f https://docs.surfercloud.com/uk8s/yaml/vpa/vpa-less-1.22.yaml2.4. Deploy a VPA object
kubectl apply -f https://docs.surfercloud.com/uk8s/yaml/vpa/deployment.yaml3. View the VPA object
kubectl describe vpa nginx-vpaThe output of the above command is the value recommended by the VPA for the Deployment.
Recommendation:
Container Recommendations:
Container Name: nginx
Lower Bound:
Cpu: 25m
Memory: 262144k
Target:
Cpu: 25m
Memory: 262144k
Uncapped Target:
Cpu: 25m
Memory: 262144k
Upper Bound:
Cpu: 50032m
Memory: 107227776429