题目:
Given an existing Kubernetes cluster running version 1.18.8,
upgrade all of the Kubernetes control plane and node Components on the master node only to version 1.19.0 .
You are also expected to upgrade kubelet and kubectl on the master node.
Be sure to drain the master node before upgrading it and uncordon it after the upgrade.
Do not upgrade the worker nodes, etcd, the container manager, the CNl plugin, the DNs sektice or any otheraddons.
文档:
https://v1-23.docs.kubernetes.io/zh/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/
步骤:
设置成维护状态
kubectl cordon k8s-master
驱逐pod
kubectl drain k8s-master --ignore-daemonsets --delete-emptydir-data --force
登录到master节点
apt-cache policy kubeadm | grep 1.XX
apt-get install -y --allow-change-held-packages kubeadm=1.XX.2-00
kubeadm upgrade apply v1.27.2-00 --etcd-upgrade=false
升级kubelet 和kubectl
apt-get update && \
> apt-get install -y --allow-change-held-packages kubelet=1.22.x-00 kubectl=1.22.x-00
systemctl daemon-reload
systemctl restart kubelet
kubectl uncordon k8s-master