image#### In this lab we will practice doing a version upgrade on a Kubernetes cluster using Kubeadm

Agenda

In this lab we will upgrade Kubernetes cluster

you can only upgrade from one minor version at a time.

Lets Practice

Task: Create Kubernetes cluster with 3 worker nodes.

Master: 1 node

Worker: 2 node

Hint

Solution

Create docker hub account. Docker Hub if you already have one skip this step

Open Play with Kubernetes login with your docker hub account.

Click on start

It will start a 4 hr session

create three instance

click on + ADD NEW INSTANCE three time to add three instances

imageon first instance enter below command, this node will be master node
kubeadm init --apiserver-advertise-address $(hostname -i) --pod-network-cidr 10.5.0.0/16

enter below command on first node

kubectl apply -f https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml

capture output of kubeadm join XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

image

enter captured command in second and third node

kubeadm join  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
imageimageCheck node status, all 3 nodes should be in ready state image

Task: Create a pod with below details using kubectl

name: web

image: nginx

Use Kubectl command

verify with below command

kubectl get pods
Solution

this command will create pod with image nginx and name web

kubectl run web --image=nginx

Task: Create a deployment with following details:

name: demo

image: nginx

Use Kubectl command

verify with below command

kubectl create deployment demo --image=nginx
Solution

this command will create a deployment with name demo and image nginx

kubectl run web --image=nginx

Task: Create a pod using Kubectl and expose port, port should be accessible from outside Kubernetes cluster

name: web

image: nginx

port: 80

verify with below command

kubectl get all
Solution
 kubectl expose pod web --port 80 --name=nginx-svc --type=NodePort --target-port=80

Task: Find port used by nodeport service in Kubernetes to expose container

Solution
kubectl get all

Task: Check Kubernetes version running on all nodes

Solution
kubectl get nodes

Task: Check Kubelet version running on all nodes

Solution
kubelet --version

Task: Check Kubectl version running on master nodes

Solution
kubectl version

Task: Check Kubeadm version running on master nodes

Solution
kubeadm version

Task: List available Kubeadm version on master node

Solution
yum list --showduplicates kubeadm --disableexcludes=kubernetes
yum list --showduplicates kubeadm --disableexcludes=kubernetes | grep <use the version of interest>

find 1.x.x

Task: Upgrade Kubeadm, Kubelet, Kubectl version running on master nodes

Solution
yum install -y kubeadm-1.X.x-x kubelet-1.X.x-x kubectl-1.X.x-x --disableexcludes=kubernetes

Task: Verify upgrade performed in previous step

Solution
kubeadm version
kubelet --version
kubectl version

Task: Take node1 to maintenance mode

Solution
kubectl drain node1 --ignore-daemonsets

Task: Check upgrade plan on master node

Solution
kubeadm upgrade plan

Task: Upgrade Kubernetes cluster

Solution
kubeadm upgrade apply v1.x.x

Task: Check Kubectl version running on master nodes

Solution
kubectl version

Task: Upgrade CNI

Solution
kubectl apply -f https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml

Task: Restart kubelet on node 1

Solution
systemctl daemon-reload && systemctl restart kubelet

Task: Check kubernetes version on node1

Solution
kubectl get nodes

Task: Bring node1 back from maintainence mode

Solution
kubectl uncordon node1

Task: Upgrade node 2 and 3

Solution

Task: Delete all open nodes/instances and close session

  1. Select the node and click on DELETE
  2. Repeat same for any other open nodes
  3. click close session

cleanup}}


Click on ‘Submit Feedback’ on the bottom left of the page to submit any questions/feedback.