VPA resource policy configuration¶
VPA resource policy configuration refers to the settings within the resourcePolicy section of a VerticalPodAutoscaler (VPA) manifest that define constraints and control parameters for how the autoscaler manages container resources^[400-devops__06-Kubernetes__k8s-ithelp__Day27__README.md].
Configuration Scope¶
The resource policy is configured under spec.resourcePolicy.containerPolicies^[400-devops__06-Kubernetes__k8s-ithelp__Day27__README.md]. This list allows administrators to apply specific rules to different containers.
Target Selection¶
The containerName field determines which containers are affected by the policy^[400-devops__06-Kubernetes__k8s-ithelp__Day27__README.md].
- Specific Container: You can target a specific container by its name.
- Wildcard (
*): Using*specifies that the policy applies to all containers within the target Pod^[400-devops__06-Kubernetes__k8s-ithelp__Day27__README.md].
Resource Constraints¶
The configuration allows for setting hard boundaries on the resources recommended by the VPA^[400-devops__06-Kubernetes__k8s-ithelp__Day27__README.md].
minAllowed¶
This field sets the lower bound for resource requests^[400-devops__06-Kubernetes__k8s-ithelp__Day27__README.md]. If the VPA's calculation suggests a value lower than this, the recommendation will adhere to this minimum.
maxAllowed¶
This field sets the upper bound for resource requests^[400-devops__06-Kubernetes__k8s-ithelp__Day27__README.md]. It prevents the VPA from recommending resources that exceed this limit.
These boundaries influence the VPA's Lower Bound and Upper Bound recommendations seen in the status. If a Pod's current requests fall outside these bounds (or the calculated bounds), the VPA may trigger eviction (depending on the updateMode) to enforce the new settings^[400-devops__06-Kubernetes__k8s-ithelp__Day27__README.md].
Resource Selection¶
The controlledResources field specifies which types of resources should be monitored and managed by the VPA^[400-devops__06-Kubernetes__k8s-ithelp__Day27__README.md].
- Supported Values: The available options are
cpuandmemory^[400-devops__06-Kubernetes__k8s-ithelp__Day27__README.md]. - Usage: You can specify one or both types, allowing for fine-grained control over which resources are auto-scaled.
Example Configuration¶
The following YAML demonstrates a VPA configured with a resource policy that applies to all containers (*) in the target deployment^[400-devops__06-Kubernetes__k8s-ithelp__Day27__README.md]:
apiVersion: autoscaling.k8s.io/v1
kind: VerticalPodAutoscaler
metadata:
name: hamster-vpa
spec:
targetRef:
apiVersion: apps/v1
kind: Deployment
name: hamster
updatePolicy:
updateMode: "Auto"
resourcePolicy:
containerPolicies:
- containerName: '*'
minAllowed:
cpu: 100m
memory: 50Mi
maxAllowed:
cpu: 1
memory: 500Mi
controlledResources: ["cpu", "memory"]
Related Concepts¶
Sources¶
^[400-devops__06-Kubernetes__k8s-ithelp__Day27__README.md]