# Uninstall Self-Hosted Deployment

This section describes how to safely delete a **region** from <code class="expression">space.vars.self\_hosted\_product\_name</code> using the `airctl` CLI. Region deletion should be performed carefully, as it involves removing associated configuration and metadata.

### Prerequisites & Safety Checks <a href="#prerequisites--safety-checks" id="prerequisites--safety-checks"></a>

Before proceeding with a region deletion, ensure the following:

1. **Take a complete backup** using the steps outlined in the [Backup Guide](https://platform9.com/docs/private-cloud-director/private-cloud-director/backup-and-restore#manual-backup-procedure).
   * This ensures that critical region data and configurations can be restored if needed.
2. **Verify the current regions** managed by your setup: `airctl get-regions`
   * Review the output and confirm the target region name(s) you plan to delete.
3. Ensure no ongoing deployments, upgrades, or workloads are running in the target region.
4. Gracefully terminate or migrate workloads if needed.

Example :

```bash
$ /opt/pf9/airctl/airctl get-regions --config /opt/pf9/airctl/conf/airctl-config.yaml 
Deployed Regions:
• Infra
• LON
```

### Command Syntax <a href="#command-syntax" id="command-syntax"></a>

#### Delete a specific region

To delete a specific region, use the following `airctl` command

```bash
airctl unconfigure-du \
  --config /opt/pf9/airctl/conf/airctl-config.yaml \
  --region <REGION_NAME>
```

This command will uninstall and remove configured regions along with all infrastructure software like consul, vault, percona, k8sniff, etc.

Options:

* `--region <REGION_NAME>` – Deletes the specified region.
* **Omit the `--region` flag** to delete *all* configured regions.
* Use the `--force` flag if the region deployment was halted or failed midway. This forces cleanup even when the state is inconsistent.

Use the `--force` flag if the region deployment was halted or failed midway. This forces cleanup even when the state is inconsistent.

{% hint style="info" %}
Use the `--force` flag if the region deployment was halted or failed midway. This forces cleanup even when the state is inconsistent.
{% endhint %}

Example:

```bash
airctl unconfigure-du --config /opt/pf9/airctl/conf/airctl-config.yaml --region LON
```

#### Verification & Cleanup <a href="#verification--cleanup" id="verification--cleanup"></a>

After deletion, verify that the region has been successfully removed. The deleted region should no longer appear in the list of active regions.

```bash
$ /opt/pf9/airctl/airctl get-regions --config /opt/pf9/airctl/conf/airctl-config.yaml 
Deployed Regions:
• Infra
```

If you plan to reuse the same nodes to deploy a new self-hosed <code class="expression">space.vars.product\_name</code> environment, make sure to also run the following command on all nodes first.

```bash
rm -rf airctl* install-pcd.sh nodelet* options.json pcd-chart.tgz /opt/pf9/airctl/ .airctl/
```

#### Delete the Management Cluster <a href="#delete-the-management-cluster" id="delete-the-management-cluster"></a>

The final step is to delete the cluster to complete the cleanup or redeploy from scratch.

```bash
/opt/pf9/airctl/airctl delete-cluster --config /opt/pf9/airctl/conf/airctl-config.yaml
```
