Autopilot — Automatic resource scaling
Automatic resource scheduling is implemented via the Vertical Pod Autoscaler dynamic configuration.
To use this feature, configure the SchedulePolicy with scaling policies to define VPA scaling behaviour:
Each scaling policy matches multiple controller resources and defines the VPA behaviour template according to the VPA API reference.
Each scaling policy can be assigned to a specific period when it should be enforced.
Supported resources: Deployment, Daemon Set, Cron job
Use the following policy as a template. Create policy resources using:
kubectl apply -f policy.yaml -n uniskai.
apiVersion: api.profisealabs.com/v1alpha
kind: KubesitterPolicy
metadata:
name: example
labels:
purpose: example
spec:
# The policy can be suspended by setting the suspend field to true.
suspend: false
title: "An example policy"
# Select namespaces which to scale
namespaceSelector:
matchNames:
- dev
- workload1
timeZone: "Europe/Kyiv"
scaling:
enable: True
policies:
- name: recommend
updatePolicy:
updateMode: Disable
- name: autopilot
updatePolicy:
updateMode: Auto
resourcePolicy:
containerPolicies:
# Disable autoscaling for specific containers
- containerName: special-app
mode: "Off"
- containerName: "*"
# Define allowed resource range for container using multipliers
maxAllowed:
cpu: x2
memory: x2
minAllowed:
cpu: x0.5
memory: x0.5
controlledValues: RequestsOnly
- name: autopilot-light
updatePolicy:
updateMode: Auto
resourcePolicy:
containerPolicies:
- containerName: "*"
maxAllowed:
cpu: x2
memory: x2
minAllowed:
cpu: x0.5
memory: x0.5
recommenders:
- name: low
- name: autopilot-aggressive
updatePolicy:
updateMode: Auto
minReplicas: 1
resourcePolicy:
containerPolicies:
- containerName: "*"
maxAllowed:
cpu: x2
memory: x2
minAllowed:
cpu: x0.25
memory: x0.25
controlledValues: RequestsOnly
recommenders:
- name: high
schedule:
periods:
- days: [Mon, Tue, Wed, Thu, Fri]
start: 07:00:00
stop: 18:00:00
# Enable resource scaling from 7:00 until 18:00
scalingPolicies: [autopilot]
# Skip resource state checks
state: skip
# Cover all other times within these days
- days: [Mon, Tue, Wed, Thu, Fri]
state: skip
scalingPolicies: [recommend]
- days: [Sat, Sun]
state: skip
scalingPolicies: [autopilot-aggressive]
Or use Uniskai Rightsizing
The policy settings can be configured according to the needs.
Desired Utilization — the percentage representing the utilization of CPU usage to be targeted by the VPA when recommending the CPU resource requests for a container.
State Maintenance Window — to apply recommendations from VPA.
State Monitoring — to return to initial requests.
You can read more about VPA policy examples and frequently asked questions.
When configured, Autopilot checks that the Vertical Pod Autoscaler is not used with the Horizontal Pod Autoscaler (HPA) on the same resource metric (CPU or memory) by excluding the HPA-controlled metric from VPA-controlled resources.
Autopilot configures VPA to control CPU and memory when HPA is configured on custom or external metrics. To change this behaviour, you can set the controlledResources property of the container resource policy to CPU or memory only.