TKG on Azure – Upgrade Management and workload clusters from 1.4.1 to 1.5.1

Reading Time: 3 mins

To upgrade Tanzu Kubernetes Grid (TKG), you download and install the new version of the Tanzu CLI on the machine that you use as the bootstrap machine. You must also download and install base image templates and VMs, depending on whether you are upgrading clusters that you previously deployed to vSphere, Amazon EC2, or Azure. In this post, I will take you through the steps to upgrade management and workload cluster deployed on Azure having version 1.4.1 to 1.5.1

Pre checks

let’s do the prechecks before starting with cluster upgrade.

In TMC Console: Administration > Management clusters capv-mgmt

  • Check the cluster version as shown here:

In TMC Console: Clusters > click on clustername: capv-workload

  • Check the cluster version as shown here:

Upgrade CLI

Upgrade the CLI and required tools to 1.5.1 in JB, this takes few mins to complete

  • Create a file on home directory (/home/azureuser) in jumpbox with name as script-session-upgrade.sh
#!/bin/bash
read -p "Enter the Vmware customer connect username: " connectusername
read -p "Enter the Vmware customer connect password: " connectpassword
echo "######### Use this script if you are planning for an upgrade and needed to upgrade already installed CLI to latest version i.e., 1.5.1 #######"
if [[ $(which docker) && $(docker --version) ]]; then
                echo "######### Docker Installed #############"
	else
        	echo "######### Installing Docker #############"
		sudo apt-get update
		sudo apt-get install  ca-certificates curl  gnupg  lsb-release
		curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
		echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
		sudo apt-get update
		sudo apt-get install docker-ce docker-ce-cli containerd.io -y
		sudo usermod -aG docker $USER
fi
echo "################# Installing vmw-cli   ###################"
sudo docker run -itd --name vmw -e VMWUSER="$connectusername" -e VMWPASS="$connectpassword" -v ${PWD}:/files --entrypoint=sh apnex/vmw-cli
containerid=$(sudo docker ps --filter "name=vmw" --format "{{.ID}}")
echo $containerid
sudo docker exec -it $containerid sh -c 'vmw-cli ls vmware_tanzu_kubernetes_grid/1_x/PRODUCT_BINARY && vmw-cli cp tanzu-cli-bundle-linux-amd64.tar.gz /files'
sudo docker exec -it $containerid sh -c 'vmw-cli ls vmware_tanzu_kubernetes_grid/1_x/PRODUCT_BINARY && vmw-cli cp kubectl-linux-v1.22.5+vmware.1.gz /files'
rm -r ~/tanzu
mkdir $HOME/tanzu
cd $HOME/tanzu
rm ~/.config/tanzu/tkg/compatibility/tkg-compatibility.yaml
echo "################# Copying the tar files locally ###################"
sudo docker cp $containerid:/files/tanzu-cli-bundle-linux-amd64.tar.gz $HOME/tanzu
sudo docker cp $containerid:/files/kubectl-linux-v1.22.5+vmware.1.gz $HOME/tanzu
sudo docker stop $containerid
sudo docker rm $containerid
echo "################# Extracting the files ###################"
gunzip tanzu-cli-bundle-linux-amd64.tar.gz
tar -xvf tanzu-cli-bundle-linux-amd64.tar
gunzip kubectl-linux-v1.22.5+vmware.1.gz
cd $HOME/tanzu/cli
echo "################ Installing Tanzu CLI ###################"
sudo install core/v0.11.1/tanzu-core-linux_amd64 /usr/local/bin/tanzu
tanzu init
tanzu version
tanzu plugin sync
tanzu plugin list
cd ~/tanzu
chmod ugo+x kubectl-linux-v1.22.5+vmware.1
sudo install kubectl-linux-v1.22.5+vmware.1 /usr/local/bin/kubectl
cd /home/azureuser/tanzu/cli
gunzip ytt-linux-amd64-v0.35.1+vmware.1.gz
gunzip kapp-linux-amd64-v0.42.0+vmware.1.gz
gunzip kbld-linux-amd64-v0.31.0+vmware.1.gz
gunzip imgpkg-linux-amd64-v0.18.0+vmware.1.gz
chmod ugo+x ytt-linux-amd64-v0.35.1+vmware.1
chmod ugo+x imgpkg-linux-amd64-v0.18.0+vmware.1
chmod ugo+x kapp-linux-amd64-v0.42.0+vmware.1
chmod ugo+x kbld-linux-amd64-v0.31.0+vmware.1
sudo mv ./ytt-linux-amd64-v0.35.1+vmware.1 /usr/local/bin/ytt
sudo mv ./kapp-linux-amd64-v0.42.0+vmware.1 /usr/local/bin/kapp
sudo mv ./kbld-linux-amd64-v0.31.0+vmware.1 /usr/local/bin/kbld
sudo mv ./imgpkg-linux-amd64-v0.18.0+vmware.1 /usr/local/bin/imgpkg
echo "################# Verify Tanzu CLI version ###################"
tanzu version
echo "################# Verify Kubectl version ###################"
kubectl version
echo "################# Verify imgpkg version ###################"
imgpkg --version
echo "################# Verify kapp version ###################"
kapp --version
echo "################# Verify kbld version  ###################"
kbld --version
echo "################# Verify ytt version  ###################"
ytt --version
#Execute below commands: 

# Change the permissions of created .sh file: 

chmod +x script-session-upgrade.sh

# Run the shell script: 

./script-session-upgrade.sh
  • Once the script is run successfully, proceed further.
# Verify the Tanzu CLI version

tanzu version

# Verify kubectl version

kubectl version

# Check the current context and ensure it is pointing to management cluster as --admin

kubectl config get-contexts

Upgrade Management cluster to 1.5.1

  • Initiate the management cluster upgrade to 1.5.1, this should take around 30 mins to complete
tanzu management-cluster upgrade capv-mgmt --os-name ubuntu --os-version 20.04 --os-arch amd64 -y
  • In other terminal, check the logs:
podname=$(kubectl get pods -n capz-system -o=jsonpath={.items[0].metadata.name}) 

kubectl logs $podname -n capz-system -c manager -f

Once the management cluster is upgraded: Verify the version in TMC Console

  • In TMC Console: Administration > Management clusters capv-mgmt and the cluster version should be v1.22.5 as shown below

 

  • List the clusters
    tanzu cluster list --include-management-cluster

  • Info about kubernetes releases
tanzu kubernetes-release get
  • Upgrades available for a workload cluster
tanzu cluster available-upgrades get partnerse-workload

Upgrade Workload cluster to 1.5.1

Trigger workload cluster upgrade to 1.5.1, this should take around 15 mins to complete. After successful completion, version should be v1.22.5+vmware.1

tanzu cluster upgrade partnerse-workload -y

How it looks in Azure portal: Upgrade process deploys a new set of nodes(1.5.1) and deletes the existing nodes(1.4.1).

  • List the clusters and now the version should be v1.22.5
tanzu cluster list --include-management-cluster
  • Once the workload cluster is upgraded:

In TMC Console: Clusters > capv-workload