> For the complete documentation index, see [llms.txt](https://docs.perfectscale.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.perfectscale.io/enable-automation/configuring-automation-with-crd/including-a-cluster-namespace-or-workload-to-the-automation/configuring-automation-for-a-cluster-with-crd.md).

# Configuring Automation for a cluster with CRD

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

Cluster-level automation configuration allows the definition of global settings that apply to all workloads within the cluster.&#x20;

{% hint style="info" %}
You can effortlessly exclude specific namespaces and workloads from Automation. Learn more [here](https://docs.perfectscale.io/enable-automation/configuring-automation-with-crd/excluding-a-namespace-or-workload-from-the-automation-with-crd.md).
{% endhint %}

## Including a cluster in the Automation&#x20;

{% hint style="success" %}
You can also scope automation to a specific workload or namespace. The workload or namespace-level settings take precedence over global (cluster-wide) automation settings. Learn more about how to automate a specific [namespace](https://docs.perfectscale.io/enable-automation/configuring-automation-with-crd/including-a-cluster-namespace-or-workload-to-the-automation/configuring-automation-for-a-namespace-with-crd.md) or [workload](https://docs.perfectscale.io/enable-automation/configuring-automation-with-crd/including-a-cluster-namespace-or-workload-to-the-automation/configuring-automation-for-a-workload-with-crd.md).
{% endhint %}

### Configuration with additional parameters

The following cluster-level automation configuration example represents global automation settings that apply to **all workloads with the type** **Deployment** within the cluster. Additionally, there is a specified frequency of the automation actions and maintenance window, which gives you control over the automation and minimizes the impact of changes on business operations.

{% hint style="info" %}
Uncover the full range of customization options, how to implement them and tailor Automation for your application's needs [here](https://docs.perfectscale.io/enable-automation/configuring-automation-with-crd/automation-customization-with-crd.md).
{% endhint %}

**Create** a YAML file with the cluster-level automation configuration using the following template:

```yaml
apiVersion: perfectscale.io/v1
kind: ClusterAutomationConfig
metadata:
  name: cluster-automation-config
spec:
  automation:
    operational:
      stopAllAutomation: false # Global kill switch for automation (default: false)
      cleanupAllAutomation: false # Stops automation and reverts all changes, restoring original resource specifications and settings
      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
            fastOOMReaction:
              enabled: true # default, set false to opt out at this level
            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
    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
              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
                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:
                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
                fastOOMReaction:
                  enabled: true # default, set false to opt out at this level
                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 `cluster-automation-config.yaml` - the name of your file created in the previous step):

```
kubectl apply -f cluster-automation-config.yaml
```

Explore more about automation customization options [here](https://docs.perfectscale.io/enable-automation/configuring-automation-with-crd/automation-customization-with-crd.md).
