Upgrade Control Plane
Steps:
- Update kubeadm package using package manager.
- Drain the master node
- Run kubeadm upgrade plan which runs some checks
- Run kubeadm upgrade apply
- uncordon the master node
- update kubelet and kubectl
Example with commands:
- sudo apt-mark unhold kubeadm
- sudo apt-get update
- sudo apt-cache policy kubeadm
- sudo apt-get install kubeadm=$TARGET_VERSION
- sudo apt-mark hold kubeadm
- kubectl drain c1-master1 --ignore-daemonsets
- sudo kubeadm upgrade plan
- sudo kubeadm upgrade apply v$TARGET_VERSION
- kubectl uncordon c1-master1
- sudo apt-mark unhold kubectl kubelet
- sudo apt-get update
- sudo apt-get install -y kubelet=$TARGET_VERSION kubectl=$TARGET_VERSION
- sudo apt-mark hold kubectl kubelet
DEMO:
SSH to Master node
- Run apt-get update
- Run apt-cache kubeadm ==> available kubeadm versions
- Run kubectl version --short ==> what version we are on
- Run kubectl get nodes ==> lists all the nodes with kubectl version
- Run sudo apt-mark unhold kubeadm
- Run sudo apt-get update
- Run sudo apt-get install -y kubeadm=$VERSION
- Run sudo apt-unmark unhold kubeadm
- Run kubeadm version
- Run kubectl drain <hostname> --ignore-daemonsets ==> ignore user workload on this master node. Above command evicts all the pods gracefully and spin up on other master node.
- Run kubeadm upgrade plan ==> show current version and planned upgrade version on two columns.
- Run kubeadm upgrade apply $VERSION
- After the cluster upgrade, uncordon the node
- Run kubectl uncordon $host-name
Worker Node Upgrade:
Steps:
- Update kubeadm
- Drain the node
- Kubeadm upgrade node
- Update kubelet and kubeadm
- Uncordon Node.
Process:
- kubectl drain c1-node1 --ignore-dameonsets
- sudo apt-mark unhold kubeadm
- sudo apt-get update
- sudo apt-get install kubeadm=$TARGET_VERSION
- sudo apt-mark hold kubeadm
- sudo kubeadm upgrade node
- sudo apt-mark unhold kubelet kubectl
- sudo apt-get update
- sudo apt-get install -y kubelet=$TARGET_VERSION kuebctl=$TARGET_VERSION
- sudo apt-mark hold kubelet kubeadm
- kubectl uncordon c1-node1
DEMO:
SSH to worker node:
- kubectl drain <host-name> --ignore-daemonsets
- sudo apt-mark unhold kubeadm
- sudo apt-get update
- sudo apt-get install -y kubeadm=$VERSION
- sudo apt-mark hold kubeadm
- sudo kubeadm upgrade node
- once kubeadm is completed on worker node, upgrade kubelet and kubectl
- sudo apt-mark unhold kubelet kuebctl
- sudo apt-get update
- sudo apt-get install -y kubectl=<VERSION same as kubeadm> kubectl=$VERSION
- sudo apt-mark hold kubelet kubectl
Happy Learningš
Comments
Post a Comment