Cluster Upgrade
Kubernetes, and all the components that integrate it, need to be updated regularly to keep up with bug fixes, new features and security fixes.
Versioning and when to update
K8s components can work with different versions, however there are some rules:
- Nothing can have a higher version than the API Server
- Controller manager and scheduler can be one minor version below
- Kubelet and kubeproxy can be up to 3 minor versions below
- Kubectl can be between 1 below and 1 over
In the same way, only the 3 latest minor releases are officially supported by k8s at any time.
Info
The official recommendation is to always update one minor version at a time
Updating a cluster
In general, for both cluster “installation types” the general logic stays the same:
- Take the control plane nodes out
- This will make admin components down but not workloads
- As admin components are down, dying workloads will not be recreated (no controllers) but they will keep running
- Do each worker node
- Each node can be drained to move the workloads
- Other strategies involve doing all at the same time (downtime) or adding new nodes and removing the old ones
kubeadm clusters
K8s provides official documentation in the procedure. Here is the summary:
- In the control node, update
kubeadmso it supports the target version (See first withkubeadm upgrade plan)
apt update
apt cache madison kubeadm
apt install kubeadm=x.x.x- Drain the node
kubectl drain controlplane- Plan and apply the upgrade
kubeadm upgrade plan vx.x.x
kubeadm upgrade apply vx.x.x- Update kubelet and kubectl
apt install kubelet=x.x.x kubectl=x.x.x
systemctl daemon-reload
systemctl restart kubelet.service- Uncordon node
kubectl uncordon controlplane- Repeat for every control node
- For each worker then
apt update
apt cache madison kubeadm
apt install kubeadm=x.x.x
kubeadm upgrade node
apt install kubelet=x.x.x
systemctl daemon-reload
systemctl restart kubelet.service- Verify
kubectl get nodes