Configuring Automation for a workload
Learn how to effortlessly automate the right-sizing of the specific workloads
Including a workload in the Automation
Workload-level automation allows fine-tuning resource management of individual workloads. Automation configured on the workload level overrides cluster and namespace-level configuration.
Create a YAML file with the workload-level automation configuration using the following template:
apiVersion: perfectscale.io/v1
kind: WorkloadAutomationConfig
metadata:
name: workload-automation-config
namespace: your-namespace # The namespace where the configuration should be applied
spec:
targetRef:
kind: Deployment
name: workload
automation:
operational:
automationMode: "Enabled" # Enables automation for the workloads with a specific type in the cluster/namespace
timeConstraints:
wasteMaxAutomationFrequency: "30m" # Applies recommendations to decrease resources every 30 minutes
fixResiliencyMaxAutomationFrequency: "30m" # Applies recommendations to increase resources every 30 minutes
maintenanceWindow:
monday:
- "00:00-23:59"
tuesday:
- "00:00-23:59"
wednesday:
- "00:00-23:59"
thursday:
- "00:00-23:59"
friday:
- "00:00-23:59"
saturday:
- "00:00-23:59"
sunday:
- "00:00-23:59"
maintenanceWindowIgnoredForResiliency: false # deprecated, use "maintenanceWindowIgnoredMinResiliencyLevel" instead
maintenanceWindowIgnoredMinResiliencyLevel: None # Indicates the minimum resiliency risk level required to bypass maintenance window constraints and resolve the issue
restrictions:
workloadMinWasteUSDPerMonth: 5 # Activates automation only if monthly waste exceeds a set threshold (for example, $5)
cpuManagement:
request:
increaseEnabled: false # Doesn't allow PerfectScale Automation to increase CPU requests if the performance risks are observed
decreaseEnabled: true # Allows PerfectScale Automation to decrease CPU requests to minimize waste
minimumCores: -1 # If a recommendation falls below the value, the automation will implement the minimum instead
maximumCores: -1 # If a recommendation falls above the value, the automation will implement the maximum instead maximumCores: -1
limit:
keepLimit: true # Automation will maintain a non-zero CPU limit and will not set the value to zero
memoryManagement:
request:
increaseEnabled: false # Doesn't allow PerfectScale Automation to increase Memory requests if the performance risks are observed
decreaseEnabled: true # Allows PerfectScale Automation to decrease Memory requests to minimize waste
minimumGiB: -1 # If a recommendation falls below the value, the automation will implement the minimum instead
maximumGiB: -1 # If a recommendation falls above the value, the automation will implement the maximum instead
limit:
increaseEnabled: false # Doesn't allow PerfectScale Automation to increase Memory limit if the performance risks are observed
decreaseEnabled: false # Doesn't allow PerfectScale Automation to decrease Memory limit
minimumGiB: -1 # If a recommendation falls below the value, the automation will implement the minimum instead
maximumGiB: -1 # If a recommendation falls above the value, the automation will implement the maximum instead maximumGiB: -1
memoryLeakDetection:
maxMemoryIncreaseIterations:
daily: 3 # Allows automation to increase memory limit up to 3 times per day
weekly: 6 # Allows automation to increase memory limit up to 6 times per week
containers:
container1:
operational:
restrictions:
cpuManagement:
request:
increaseEnabled: false # Doesn't allow PerfectScale Automation to increase CPU requests if the performance risks are observed
decreaseEnabled: true # Allows PerfectScale Automation to decrease CPU requests to minimize waste
minimumCores: -1 # If a recommendation falls below the value, the automation will implement the minimum instead
maximumCores: -1 # If a recommendation falls above the value, the automation will implement the maximum instead
limit:
keepLimit: true # Automation will maintain a non-zero CPU limit and will not set the value to zero
memoryManagement:
request:
increaseEnabled: false # Doesn't allow PerfectScale Automation to increase Memory requests if the performance risks are observed
decreaseEnabled: true # Allows PerfectScale Automation to decrease Memory requests to minimize waste
minimumGiB: -1 # If a recommendation falls below the value, the automation will implement the minimum instead
maximumGiB: -1 # If a recommendation falls above the value, the automation will implement the maximum instead
limit:
increaseEnabled: false # Doesn't allow PerfectScale Automation to increase Memory limit if the performance risks are observed
decreaseEnabled: false # Doesn't allow PerfectScale Automation to decrease Memory limit
minimumGiB: -1 # If a recommendation falls below the value, the automation will implement the minimum instead
maximumGiB: -1 # If a recommendation falls above the value, the automation will implement the maximum instead
memoryLeakDetection:
maxMemoryIncreaseIterations:
daily: 3 # Allows automation to increase memory limit up to 3 times per day
weekly: 6 # Allows automation to increase memory limit up to 6 times per weekApply the created configuration by running the following command (where workload-automation-config.yaml - the name of your file created in the previous step)
Automating workloads with a specific type
DaemonSet
Create a YAML file with the workload-level automation configuration using the following template:
Apply the created configuration by running the following command (where your-workload-automation-config.yaml - the name of your file created in the previous step)
StatefulSet
Create a YAML file with the workload-level automation configuration using the following template:
Apply the created configuration by running the following command (where your-workload-automation-config.yaml - the name of your file created in the previous step)
CronJob and Job
Create a YAML file with the workload-level automation configuration using one of the following templates:
CronJob configuration
Job configuration
Apply the created configuration by running the following command (where your-workload-automation-config.yaml - the name of your file created in the previous step)
Automating workloads by label
You can easily configure automation for specific workloads by using labels. To do so, add the workloadLabelSelectors section to your cluster-level or namespace-level configuration. Specify the label key and value, then choose whether to enable or disable automation for workloads with the given label.
Expected behavior:
If
workloadLabelSelectorsis empty or not set, automation configurations will be applied according to the other configurations in place.If
workloadLabelSelectorsonly contains labels withallowAutomation: true, automation configurations will be applied only to the workloads that match at least one label specified in this configuration.If
workloadLabelSelectorsonly contains labels withallowAutomation: false, automation configurations will be applied solely to workloads that do not match any specified labels in this configuration.If
workloadLabelSelectorscontains a mix of labels withallowAutomation: falseandallowAutomation: true, automation configurations will be applied to workloads that match the labels withallowAutomation: trueand do not match the labels withallowAutomation: falsein this configuration.
Label-based automation execution logic
When autonomous optimization is configured using labels, PerfectScale applies the following logic:
Check the
labelssection in the Automation CR.Check the configurations applied to workloads that have these labels, including the
automationModevalue.
To automate workloads using labels, ensure an exact match between the labels defined in the Automation CR and the labels applied to the target workloads. If the labels do not match exactly, the workload will not be automated.
Expected results example
✅ Automated workloads
As a result of the Automation CR configuration above, PerfectScale verifies that automationMode is set to Enabled and checks the workloadLabelSelectors. Automation will be applied to all workloads in the specified namespace that match at least one configured label with allowAutomation: true, and do not match label with allowAutomation:false.
In this case, the automation mode is applied according to the default merge logic based on the cluster- or namespace-level configuration.
🔴 Non-automated workloads
As a result of the Automation CR configuration above, PerfectScale verifies that automationMode is set to Enabled and checks the workloadLabelSelectors. Workloads with allowAutomation: false, as well as workloads in the specified namespace that do not have at least one label with allowAutomation: true, will not be automated.
Automating ephemeral workloads
PerfectScale's advanced Automation empowers you to effortlessly optimize K8s workloads, even in highly dynamic and complex environments. By optimizing workloads with a transient nature, you can ensure that you’re not over-provisioning or paying for unused capacity, significantly reduce cloud costs, and meet performance demands without latency or bottlenecks.
By grouping ephemeral workloads with specific workload labels, PerfectScale automates the optimization of ephemeral workloads such as:
Airflow
Knative
Spark jobs
Temporal
Github actions
and more
Step 1: Group ephemeral workloads by labels
To automate the optimization of ephemeral workloads, you first need to group them by applying specific labels. This is done by adding predefined labels to each workload. For detailed instructions on how to group ephemeral workloads, refer to this page.
Step 2: Apply CR that contains these labels
For workloads with a custom type, automation is enabled by setting up a Custom Resource (CR), where you can specify all the necessary configurations.
Create a YAML file with the automation configuration and indicate the custom workload type:
Apply the created configuration by running the following command (where workload-automation-config.yaml - the name of your file created in the previous step)
Last updated
Was this helpful?