# Configuring Automation for a cluster with CRD

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](/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](/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](/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](/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:

<pre class="language-yaml"><code class="lang-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:
<strong>              increaseEnabled: false # Doesn't allow PerfectScale Automation to increase CPU requests if the performance risks are observed
</strong>              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
    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
              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
</code></pre>

**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](/enable-automation/configuring-automation-with-crd/automation-customization-with-crd.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET 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?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
