# Disable automation

PerfectScale Automation is a powerful feature that streamlines and optimizes your infrastructure management. However, there may be scenarios where you need to temporarily or permanently disable automation. Choose one of the methods provided to deactivate Automation smoothly, depending on your needs.

## Disabling automation for the namespace/workload

This method enables you to selectively exclude specific namespaces and workloads within your cluster from automation.

Set a flag `spec.automation.operational.automationMode =`` `**`Disabled`** in the namespace/workload automation configuration.

{% hint style="info" %}
The **workload** settings **take precedence over** the settings of the **namespace** or **cluster** (the **namespace** settings **take precedence over** the **cluster's**). This feature allows enabling automation for the entire namespace or cluster while allowing for specific workloads to be disabled within this namespace/cluster.
{% endhint %}

Use one of the following configurations to **exclude** the particular **namespace** or **workload** from automation in the cluster.

### **Exclude namespace**

```yaml
apiVersion: perfectscale.io/v1
kind: NamespaceAutomationConfig
metadata:
  name: your-namespace-automation-config
spec:
  automation:
    operational:
      automationMode: Disabled
```

### **Exclude workload**

```yaml
apiVersion: perfectscale.io/v1
kind: WorkloadAutomationConfig
metadata:
  name: your-workload-automation-config
spec:
  automation:
    operational:
      automationMode: Disabled
  targetRef:
    kind: Deployment
    name: deployment-name-here
```

### **Exclude workload by label**

```yaml
apiVersion: perfectscale.io/v1
kind: NamespaceAutomationConfig
metadata:
  name: your-namespace-automation-config
spec:
  automation:
    operational:
      workloadLabelSelectors:
        - key: "environment"
          value: "production"
          allowAutomation: false    # Disables Automation for workload with the specified label
```

## Disable automation for the cluster

To disable automation for the entire cluster, use one of the following options:

* Set a flag `spec.automation.operational.StopAllAutomation = true` in the cluster automation configuration.
* Manually delete the cluster automation configuration.
* Uninstall PerfectScale Automation Agent.

### StopAllAutomation

This method allows you to fully disable automation across the entire cluster, overriding any existing automation settings for specific namespaces or workloads.&#x20;

```yaml
apiVersion: perfectscale.io/v1
kind: ClusterAutomationConfig
metadata:
  name: cluster-automation-config
spec:
  automation:
    operational:
        stopAllAutomation: true
```

## Cleanup automation

In certain scenarios, you may need to disable automation and revert any changes it has applied, returning your cluster to its original state based on the specified configuration.&#x20;

To achieve this, set the `cleanupAllAutomation` parameter to `true`. This will not only stop automation but also roll back any modifications made by the automation processes, restoring the original resource specifications and settings.

{% hint style="info" %}
`cleanupAllAutomation` overrides any existing automation settings for specific namespaces or workloads.&#x20;
{% endhint %}

```yaml
apiVersion: perfectscale.io/v1
kind: ClusterAutomationConfig
metadata:
  name: cluster-automation-config
spec:
  automation:
    operational:
        cleanupAllAutomation: true
```

## Uninstall the automation agent

To uninstall the PerfectScale Automation Agent, execute the following command

```yaml
helm -n perfectscale  uninstall psc-autoscaler
```
