For the complete documentation index, see llms.txt. This page is also available as Markdown.

Configuring Automation for a namespace with CRD

Learn how to apply Automation to all workloads within the namespace effortlessly

Including a namespace in the Automation

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
      duringRolloutInProgress: pause # A default behavior that prevents Automation from applying new recommendations when concurrent ReplicaSets are identified
      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
            cpuRunawayDetection:
              maxCpuRequestIncreaseIterations:
                daily: 3 # Allows automation to increase cpu request up to 3 times per day
                weekly: 6 # Allows automation to increase cpu request up to 6 times per week
          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 # 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
                cpuRunawayDetection:
                  maxCpuRequestIncreaseIterations:
                    daily: 3 # Allows automation to increase cpu request up to 3 times per day
                    weekly: 6 # Allows automation to increase cpu request up to 6 times per week
              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
      Rollout:
        operational:
          automationMode: "Enabled" # Enables rollout support

Apply the created configuration by running the following command (where namespace-automation-config.yaml - the name of your file created in the previous step)

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:

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)

Explore more about automation customization options here.

Automating kube-system namespace in AKS clusters

Azure Kubernetes Service has a known limitation that prevents tools from managing resources within the kube-system namespace by default. To enable automation in this namespace, it is necessary to add the following annotation to allow Admissions Enforcer to ignore it:

Last updated

Was this helpful?