VPA — automatically adjusts Pod resource requests/limits.
1apiVersion: autoscaling.k8s.io/v12kind: VerticalPodAutoscaler3metadata:4 name: myapp-vpa5spec:6 targetRef:7 apiVersion: apps/v18 kind: Deployment9 name: myapp10 updatePolicy:11 updateMode: "Off" # Recommendations only12 resourcePolicy:13 containerPolicies:14 - containerName: app15 minAllowed:16 cpu: "100m"17 memory: "128Mi"18 maxAllowed:19 cpu: "4"20 memory: "4Gi"21 controlledResources: ["cpu", "memory"]22 controlledValues: RequestsAndLimits23 - containerName: sidecar24 mode: "Off" # Don't touch this container25---26# Auto mode (recommended for non-critical)27apiVersion: autoscaling.k8s.io/v128kind: VerticalPodAutoscaler29metadata:30 name: myapp-vpa-auto31spec:32 targetRef:33 apiVersion: apps/v134 kind: Deployment35 name: myapp36 updatePolicy:37 updateMode: "Auto"38 minReplicas: 2
1# Install VPA2kubectl apply -f vpa-crd.yaml3kubectl get vpa4kubectl describe vpa myapp-vpa56# Check recommendations7kubectl get vpa myapp-vpa -o yaml | grep -A 10 recommendations
Update Modes:
vs HPA: