Kubespray provides additional playbooks to manage your cluster: you can upgrade your cluster by running the upgrade-cluster.yml
playbook. The reasons that can lead to updating your cluster may be due to an update of the GitHub repository or because you want to make some customizations. In practice, the update command is similar to that seen for cluster deployment
The difference lies in the playbook used, of course. Components are upgraded in the order in which they were installed in the Ansible playbook. The order of component installation is as follows:
- Docker
- etcd
- kubelet and kube-proxy
- network_plugin (such as Calico or Weave)
- kube-apiserver, kube-scheduler, and kube-controller-manager
- Add-ons (such as KubeDNS)
It is important to note that upgrade-cluster.yml
can only be used for upgrading an existing cluster. That means there must be at least 1 kube-master already deployed. Anyway, before launching the update, let's see a handful of parameters that can be changed and what to do in order not to run into versioning problems.
Plan your cluster deployment
The main files to be analyzed and modified for the configuration of our cluster are:
- inventory/mycluster/group_vars/all/all.yml;
- inventory/mycluster/group_vars/k8s-cluster/addons.yml;
- inventory/mycluster/group_vars/k8s-cluster/k8s-cluster.yml;
- inventory/mycluster/group_vars/k8s-cluster/k8s-net-<cni_chosen>.yml.
In particular, the second on the list allows you to find applications such as Helm, Metrics Server, Nginx ingress controller, etc. already installed in the cluster. The third allows you to choose the destination path of k8s files, the CNI (calico, cilium, weave or flannel), the CRI (docker, cri-o, containerd) and much more. Furthermore, it offers the possibility to access the Kubernetes API directly from the SA, even if it is not part of the cluster, and to install Netchecker, which thanks to its agents ensures connectivity between the Pods.
Multiple upgrades
Attention
Attempting to upgrade from an older release straight to the latest release is unsupported and likely to break something: do not skip releases when upgrading, but by one tag at a time.
For instance, if you're on v2.13.1, then check out v2.13.2, run the upgrade, check out the next tag, and run the next upgrade, etc. Proceed in this way until the latest version of the repository. To manage the repository tags, run the following commands inside the kubespray
folder
Therefore, update the cluster with the command at the beginning of the page, starting with the v2.13.2 tag and so on up to the v2.15.0 tag. It is inevitable that in the updating phase, from time to time, small manual interventions may be necessary.