in this section we going to see how to do some update to a cluster
for update the folder /etc/apt/sources.list.d/kubernetes.list
cat /etc/apt/sources.list.d/kubernetes.list
deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /
for update a node you need to take off the node from cluster we say the node go in maintenance
if you just down a node the kube-controller-manager --pod-eviction-tiemout=5m0s by default take 5minutes before restart pode somewhere else on the cluster so not a good idea
so there is a safer way
this wil stop all the pod on the specify node and restart on other node and you can do your action reboot or whatever you want
kubectl drain <node-name>
# its for ignore some pods that was auto created like network pods
kubectl drain <node-name> --ignore-daemonsets
to return the node inside the cluster but the previous pods wil not return automatically to the node
kubectl uncordon <node-name>
if a pod is create without deployement or replicat you have to force the drain and the pods will not be recreated on an other node
when you get the node you see the version of kube
controlplane ~ ✖ kubectl get node
NAME STATUS ROLES AGE VERSION
controlplane Ready control-plane 8m33s v1.31.0
node01 Ready <none> 7m55s v1.31.0
the construction is :
there is also alpha and beta version this is version can have some bug
don't forget that there is many component in a kube cluster like kubelet scheduler apiserver controller manager and kubeproxy that should have the same version (its a bit more complicated but lets do this simple)
for do an update is only minor version by minor version do not go to 1.28 to 1.31
so master worker node like a basic node first you do the master node
if you have only one master during this period youre cluster is down but the pod continue to work but if a pods crash don't panic and wait master return to up status
after you can upgrade worker node one by one
for upgrade a node we use kubeadm
this commmand give you a lot of information current and available version
kubeadm upgrade plan
dont forget kubelet have to be upgrade manually on each node
first on master upgrade the kubeadm
apt-get upgrade -y kubeadm=<new-version>
#exemple
apt-get upgrade -y kubeadm=1.30.0-00
then upgrade with kubeadm plan only for master node
kubeadm upgrade apply v1.30.0
apt-get upgrade -y kubelet=1.30.0-00
systemctl restart kubelet
#on master node
controlplane ~ ➜ kubectl get node
NAME STATUS ROLES AGE VERSION
controlplane Ready control-plane 44m v1.30.0
node01 Ready <none> 43m v1.29.0
then you can pass all you worker one by one in maintenance then update the kubelet
a little lsit of command
kubectl drain <node-name>
apt-get upgrade -y kubeadm=1.30.0-00
kubeadm upgrade node config --kubelet-version v1.30.0
systemctl restart kubelet
kubectl uncordon <node-name>
you can freeze a node like no other pods will be created on this node with this command
kubectl cordon <node-name>