# Part 4: Upgrade

## What Will You Do

In part 4, you will:

- Upgrade the control plane kubernetes version

Watch a video of this exercise.

Upgrade AKS Cluster: Getting Started with Rafay Terraform Provider for AKS - YouTube

## Assumptions

This part assumes that you have completed [Part 1](https://docs.rafay.co/learn/quickstart/aks/clusterlifecycle/provision/) of this series and have a successfully provisioned and healthy AKS cluster.

## Step 1: Upgrade Control Plane and Node Pools

In this step, you will upgrade the kubernetes version for the control plane and the node pools.

Confirm the current control plane version of the cluster

- Navigate to the previously created project in your Org
- Go to Infrastructure -> Clusters and view the current version of the control plane

Confirm the current node pool version of the cluster

- Select Infrastructure -> Clusters
- Click on the cluster name on the cluster card
- Click the "Nodes" tab
- Expand the node card to see the version

- Select Infrastructure -> Clusters
- Click on "Upgrade Available" on the cluster card
- Select the version to upgrade to
- Select "Control Plane + Node Pools" for the AKS Version Upgrade Type
- Select the node pools to be upgraded
- Click "Upgrade"

The upgrade process will begin upgrading the control plane

The upgrade process will then move to upgrading the node pools

The completed upgrade will look like the below:

## Download and Update Configuration

Download the current cluster config from the existing cluster

- Go to Infrastructure -> Clusters. Click on the settings icon of the cluster and select "Download Cluster Config"
- Update the downloaded specification file with the desired "kubernetesVersion" for the control plane
- Update the downloaded specification file with the desired "orchestratorVersion" for the node pool

```
kubernetesVersion: 1.23.12
orchestratorVersion: 1.23.12
```

The updated YAML file will look like this:

```
apiVersion: rafay.io/v1alpha1
kind: Cluster
metadata:
  name: aks-get-started-cluster
  project: aks
spec:
  blueprint: default-aks
  cloudprovider: Azure-CC
  clusterConfig:
    apiVersion: rafay.io/v1alpha1
    kind: aksClusterConfig
    metadata:
      name: aks-get-started-cluster
    spec:
      managedCluster:
        apiVersion: "2022-07-01"
        identity:
          type: SystemAssigned
        location: centralindia
        properties:
          apiServerAccessProfile:
            enablePrivateCluster: true
          dnsPrefix: aks-get-started-cluster-dns
          kubernetesVersion: 1.23.12
          networkProfile:
            loadBalancerSku: standard
            networkPlugin: kubenet
        sku:
          name: Basic
          tier: Free
        type: Microsoft.ContainerService/managedClusters
      nodePools:
      - apiVersion: "2022-07-01"
        location: centralindia
        name: primary
        properties:
          count: 2
          enableAutoScaling: true
          maxCount: 2
          maxPods: 40
          minCount: 2
          mode: System
          orchestratorVersion: 1.23.12
          osType: Linux
          type: VirtualMachineScaleSets
          vmSize: Standard_DS2_v2
        type: Microsoft.ContainerService/managedClusters/agentPools
      resourceGroupName: Rafay-ResourceGroup
  proxyconfig: {}
  type: aks
```

- Execute the following command to begin the upgrade of the control plane and node pool. Note, update the file name in the below command with the name of your updated specification file

```
./rctl apply -f aks-get-started-cluster-config.yaml
```

**_Expected output (with a task id):_**

```
{
  "taskset_id": "j2q8e82",
  "operations": [\
    {\
      "operation": "ClusterUpgrade",\
      "resource_name": "aks-get-started-cluster",\
      "status": "PROVISION_TASK_STATUS_PENDING"\
    }\
  ],
  "comments": "The status of the operations can be fetched using taskset_id",
  "status": "PROVISION_TASKSET_STATUS_PENDING"
}
```

From the web console, you can see that the upgrade is in progress. Note that the upgrade can take up to 15 minutes to complete.

Once the upgrade is complete, you can see that the kubernetes version of the cluster control plane has been upgraded.

You can see that the kubernetes version of the node pool has been upgraded as well.

## Monitor Upgrade

From the web console, we can see that the upgrade is in progress. Note that the upgrade can take up to 40 minutes to complete.

Once the upgrade is complete, we can see that the kubernetes version of "both" the cluster control plane and the worker nodes have been upgraded.

## Recap

Congratulations! At this point, you have

- Successfully upgraded the control plane version of the cluster
- Successfully upgraded the node pool version
