# Upgrade SMCP 5.6 patch-4 to SMCP 5.9

1. Take a backup of the 5.6 management plane by following the [backup guide](https://github.com/platform9/pcd-docs-gitbook/blob/main/PEC/backup-guide/README.md).
2. Destroy the older`1.21` based nodelet cluster using the following commands.

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

```bash
airctl stop
airctl unconfigure-du --force 
airctl advanced-ddu delete-mgmt
```

{% endtab %}
{% endtabs %}

3. Ensure the older`/etc/nodelet/airctl-mgmt/certs` directory is cleaned up.
4. Download newer `5.9` based artifacts using the download script. Run the `install.sh` script to extract and place the artifacts under `/opt/pf9/airctl` directory.

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

```bash
bash install.sh v-5.9.x-<airctl version>
```

{% endtab %}
{% endtabs %}

Refer the [SMCP 5.9 release notes](https://platform9.com/docs/v5.9/PEC/lts3-release-notes) for the exact `airctl` version used by the `install.sh` script.

For example, when upgrading to SMCP v5.9.0 :

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

```bash
bash install.sh v-5.9.0-2847602
```

{% endtab %}
{% endtabs %}

When upgrading to SMCP v5.9.1 :

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

```bash
bash install.sh v-5.9.1-3097398
```

{% endtab %}
{% endtabs %}

5. Ensure that the management cluster host has configuration of at least 8vCPU, 32GB memory and 250GB disk.
6. Install the pre-requisite `container-selinux` package if not installed.
7. Update the config files as suggested below and deploy the new`1.25` based nodelet management cluster by running the following command.

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

```bash
airctl advanced-ddu create-mgmt
```

{% endtab %}
{% endtabs %}

Ensure that the `airctl-config.yaml` file is updated to have the new airctl build number.

In the `nodelet-bootstrap.yaml` file ensure that `systemImages` param is set to use newer LTS3 kubedu and nodelet image tar files (the release you are upgrading to). And the userImages section points to previous version of kubedu image tars (the release you are upgrading from).

Also add `isAirgapped: true` in `nodelet-bootstrap.yaml` if it is offline mode. A snippet of the `nodelet-bootstrap.yaml` is shown below.

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

```yaml
isAirgapped: true
systemImages:
- /opt/pf9/airctl/imgs/kubedu-imgs-v-5.9.0-2847602.tar.gz
- /opt/pf9/airctl/imgs/nodelet-imgs-v-5.9.0-2847602.tar.gz
userImages:
- /home/centos/patch2/kubedu-imgs-v-5.6.7-2624593.tar.gz
- /home/centos/patch4/kubedu-imgs-v-5.6.7-2658688.tar.gz
```

{% endtab %}
{% endtabs %}

8. Run the restore command by following the [restore guide](https://github.com/platform9/pcd-docs-gitbook/blob/main/PEC/restore-guide/README.md) for the `5.6` management plane on top of `1.25` nodelet cluster.
9. Ensure that the DU is in ready state by running the following command and waiting for it to be ready. Check the status of hosts restored.

```bash
airctl status
airctl host-status
```

After restore, we should be able to login to UI and view the existing workload clusters.

10. To upgrade the DU components to`5.9`, follow the [upgrade guide](https://github.com/platform9/pcd-docs-gitbook/blob/main/PEC/Upgrade-guide/README.md). Note: In order to avoid any possible ImagePullBackOff errors during upgrade/upgrade-hosts steps that can happen in some rare cases, refer [additional-information](https://platform9.com/kb/PEC/while-upgrade-from-lts2-patch2-to-scmp--management-plane-cluster#additional-information)

Wait until the DU is back in ready state after upgrade by using following command.

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

```bash
airctl status
{% endtab %}
{% tab language="none" %}
// Click to edit code
```

{% endtab %}
{% endtabs %}

Login to the GUI and ensure that it shows the version as 5.9.

11. At this point the DU components are upgraded to LTS3. We can now push the new images for 1.24 and 1.25 Kubernetes workload clusters to our private docker registry (if using `privateRegistryType: DU` in airctl-config.yaml) using the following command.

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

```bash
sudo airctl advanced-du push-images --img-tar [tar file name]
```

{% endtab %}
{% endtabs %}

The new images are stored under the `/opt/pf9/airctl/imgs/` directory and each file has a k8s prefix. A handy one-liner to push all images is.

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

```bash
ls -l /opt/pf9/airctl/imgs/k8s* | xargs -I{} sh -c "sudo /opt/pf9/airctl/airctl --config /opt/pf9/airctl/conf/airctl-config.yaml advanced-du push-images --img-tar {}"
```

{% endtab %}
{% endtabs %}

12. We can upgrade the host side components, by running the following 2 commands.

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

```bash
airctl configure-hosts --reset-pf9-managed-docker-conf --skip-docker-install --skip-docker-img-import
airctl upgrade-hosts
```

{% endtab %}
{% endtabs %}

After the upgrade-hosts command, wait for DU task state to be in ready state again by running the following command.

Check the host status after upgrading hosts.

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

```bash
airctl status
airctl host-status
```

{% endtab %}
{% endtabs %}

At this point all the components have been upgraded to SMCP 5.9 (LTS3). Now, we can proceed with the actual workload cluster upgrades either using the GUI or API.

{% hint style="warning" %}
**Consul Issue:**

After restore, errors seen in the consul pod saying 'ACL not found', which are harmless and can be ignored.

So, we are currently skipping the consul upgrade in the upgrade step and installing the upgraded consul in the restore process itself.
{% endhint %}
