The following example of a namespace-level automation configuration allows you to customize automation settings for specific namespaces, catering to the needs of different applications. This example shows how to automate optimization for all Deployment-type workloads in the namespace.
Create a YAML file with the namespace-level automation configuration using the following template:
apiVersion: perfectscale.io/v1
kind: NamespaceAutomationConfig
metadata:
name: namespace-automation-config
namespace: your-namespace # The namespace where the configuration should be applied
spec:
automation:
operational:
automationMode: "Enabled" # Enables automation for a specific 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 # Indicates if the maintenance window constraints are ignored for resiliency
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
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 inst
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 week
workloadTypes:
Deployment:
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 # Indicates if the maintenance window constraints are ignored for resiliency
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
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 week
Apply the created configuration by running the following command (where namespace-automation-config.yaml - the name of your file created in the previous step)
kubectl apply -f namespace-automation-config.yaml
Automating multiple namespaces with a single configuration
If you want to apply the same configuration to multiple namespaces, remove namespace: your-namespace from the configuration and apply the configuration with the following command for each namespace kubectl apply -f namespace-automation-config.yaml -n namespace, where namespace - the namespace where it will be applied.
If a namespace is specified neither in the configuration nor in the command, the configuration will be applied to the default namespace.
Automating kube-system namespace
By default, PerfectScale does not automate the kube-system namespace. To enable automation for this namespace, follow these simple steps.
Remove the kube-system namespace from the excludedNamespaces (is only needed if you are using Autoscaler v1.0.6 and older).
Create a YAML file with the namespace-level automation configuration using the following template:
apiVersion: perfectscale.io/v1
kind: NamespaceAutomationConfig
metadata:
name: kube-system-ns-config
namespace: kube-system # The namespace where the configuration should be applied
spec:
automation:
operational:
automationMode: "Enabled" # Enables automation for a specific namespace
restrictions:
workloadMinWasteUSDPerMonth: 5 # Activates automation only if monthly waste exceeds a set threshold (for example, $5)
cpuManagement:
request:
increaseEnabled: true # Allows PerfectScale Automation to increase CPU requests if the performance risks are observed
decreaseEnabled: true # Allows PerfectScale Automation to decrease CPU requests to minimize waste
limit:
keepLimit: false # Automation can set the CPU limit to zero
memoryManagement:
request:
increaseEnabled: true # Allows PerfectScale Automation to increase Memory requests if the performance risks are observed
decreaseEnabled: true # Allows PerfectScale Automation to decrease Memory requests to minimize waste
limit:
increaseEnabled: true # Allows PerfectScale Automation to increase Memory limit if the performance risks are observed
decreaseEnabled: true # Allows PerfectScale Automation to decrease Memory limit
Apply the created configuration by running the following command (where kube-system-ns-config.yaml - the name of your file created in the previous step)
kubectl apply -f kube-system-ns-config.yaml
Explore more about automation customization options here.