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
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
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
enter captured command in second and third node
kubeadm join XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Task: Create a pod with below details using kubectl
name: web
image: nginx
Use Kubectl command
verify with below command
kubectl get pods
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
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
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
kubectl get all
Task: Check Kubernetes version running on all nodes
kubectl get nodes
Task: Check Kubelet version running on all nodes
kubelet --version
Task: Check Kubectl version running on master nodes
kubectl version
Task: Check Kubeadm version running on master nodes
kubeadm version
Task: List available Kubeadm version on master node
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
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
kubeadm version
kubelet --version
kubectl version
Task: Take node1 to maintenance mode
kubectl drain node1 --ignore-daemonsets
Task: Check upgrade plan on master node
kubeadm upgrade plan
Task: Upgrade Kubernetes cluster
kubeadm upgrade apply v1.x.x
Task: Check Kubectl version running on master nodes
kubectl version
Task: Upgrade CNI
kubectl apply -f https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml
Task: Restart kubelet on node 1
systemctl daemon-reload && systemctl restart kubelet
Task: Check kubernetes version on node1
kubectl get nodes
Task: Bring node1 back from maintainence mode
kubectl uncordon node1
Task: Upgrade node 2 and 3
Task: Delete all open nodes/instances and close session