> For the complete documentation index, see [llms.txt](https://docs.platform9.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.platform9.com/private-cloud-director/getting-started/self-hosted/cluster-scaling.md).

# Cluster Scaling & Other Operations

This document describes steps to scale your K3s management cluster that is part of your self-hosted <code class="expression">space.vars.product\_name</code> deployment.

## Scale Up Management Cluster

Let's consider that we have 3 master nodes as part of your management cluster, with IP addresses ``1.1.1.1, 2.2.2.2 `and` 3.3.3.3``.

{% tabs %}
{% tab title="K3s Bootstrap Config File" %}

```bash
$ cat /opt/pf9/airctl/conf/k3s-bootstrap-config.yaml
...
masterNodes:
- nodeName: 1.1.1.1
- nodeName: 2.2.2.2
- nodeName: 3.3.3.3
```

{% endtab %}
{% endtabs %}

Lets say that you want to scale up the management cluster to 5 nodes, and that `4.4.4.4 & 5.5.5.5` are the IP addresses of the 2 new nodes to be added.

To scale up the number of cluster nodes to 5:

* Configure the [pre-requisites](/private-cloud-director/getting-started/self-hosted/self-hosted-pre-requisites.md) on the two new nodes.
* Edit the cluster bootstrap configuration file `/opt/pf9/airctl/conf/k3s-bootstrap-config.yaml` and add the two new IP addresses to the section called `masterNodes` in the file.
* Finally, run the `airctl` command shown below to scale up the cluster.

{% hint style="info" %}
**Note**

`airctl` expects the node count to be always odd in the cluster bootstrap configuration file `/opt/pf9/airctl/conf/k3s-bootstrap-config.yaml`
{% endhint %}

{% tabs %}
{% tab title="k3s Bootstrap Config File" %}

```bash
$ cat /opt/pf9/airctl/conf/k3s-bootstrap-config.yaml
...
masterNodes:
- nodeName: 1.1.1.1
- nodeName: 2.2.2.2
- nodeName: 3.3.3.3
- nodeName: 4.4.4.4
- nodeName: 5.5.5.5
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Scale Command" %}

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

{% endtab %}
{% endtabs %}

Now verify that the management cluster has scaled up by querying the cluster nodes.

{% tabs %}
{% tab title="Cluster State Post Scale Up" %}

```bash
$ kubectl get nodes
NAME           STATUS   ROLES                        AGE      VERSION
1.1.1.1        Ready    control-plane,etcd,master    4d23h    v1.33.9+k3s1
2.2.2.2        Ready    control-plane,etcd,master    4d23h    v1.33.9+k3s1
3.3.3.3        Ready    control-plane,etcd,master    4d23h    v1.33.9+k3s1
4.4.4.4        Ready    control-plane,etcd,master    5m42s    v1.33.9+k3s1
5.5.5.5        Ready    control-plane,etcd,master    5m40s    v1.33.9+k3s1
```

{% endtab %}
{% endtabs %}

## Management Cluster Status

To check the status of your management cluster, run the following command:

{% tabs %}
{% tab title="Bash" %}

```bash
airctl status --config /opt/pf9/airctl/conf/airctl-config.yaml --region <REGION_NAME>
```

{% endtab %}
{% endtabs %}

Sample output:

{% tabs %}
{% tab title="Bash" %}

```bash
airctl status --config /opt/pf9/airctl/conf/airctl-config.yaml --region foo-region1
# Sample output:
------------- deployment details ---------------
fqdn:                foo-region1.bar.io
cluster:             foo-bork.bar.io
region:              foo-region1
task state:          ready
version:             v-5.12.0-3479469
-------- region service status ----------
desired services:  45
ready services:    45
```

{% endtab %}
{% endtabs %}

## Scale Down Management Cluster

Now let's assume that we want to remove nodes `2.2.2.2` and `3.3.3.3` from the management cluster. To scale down the cluster:

* Edit the cluster bootstrap configuration file and remove the IP addresses of the two nodes.
* Then run the `airctl` command as shown below to scale down the cluster.

{% tabs %}
{% tab title="K3s Bootstrap Config File" %}

```bash
$ cat /opt/pf9/airctl/conf/k3s-bootstrap-config.yaml
...
masterNodes:
- nodeName: 1.1.1.1
- nodeName: 4.4.4.4
- nodeName: 5.5.5.5
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Scale Command" %}

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

{% endtab %}
{% endtabs %}

* Cluster state post scale down operation completion:

{% tabs %}
{% tab title="Cluster State Post Scale Down" %}

```bash
$ kubectl get nodes
NAME            STATUS   ROLES                        AGE      VERSION
1.1.1.1         Ready    control-plane,etcd,master    4d23h   v1.33.9+k3s1
4.4.4.4         Ready    control-plane,etcd,master    5m42s    v1.33.9+k3s1
5.5.5.5         Ready    control-plane,etcd,master    5m40s    v1.33.9+k3s1
```

{% endtab %}
{% endtabs %}

## Uninstall Self-Hosted Deployment

To uninstall the specific region of your self-hosted deployment, run the following command. If you want to uninstall all regions, just remove `--region` flag.

{% tabs %}
{% tab title="Bash" %}

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

{% endtab %}
{% endtabs %}

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

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.

{% tabs %}
{% tab title="Bash" %}

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

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.platform9.com/private-cloud-director/getting-started/self-hosted/cluster-scaling.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
