大纲
目标当前线上k8s集群版本是k8s1.17 想把k8s升级到1.18。注意k8s不能跨版本升级例如k8s1.17不能直接升级到k8s1.19,需要先升级到1.18才后向后升级
当前证书情况
kubeadm alpha certs check-expiration
查看kubeadm版本
查看kubeadm版本
apt-get update
apt-cache madison kubeadm
下载更新最新的kubeadm
下载kubeadm
apt-get update
apt-get install -y --allow-change-held-packages --allow-downgrades kubeadm=1.18.0-00
查看升级计划
kubeadm upgrade plan
注意事项:
可能会出现异常
kubeadm upgrade plan
[upgrade/config] Making sure the configuration is correct:
[upgrade/config] Reading configuration from the cluster...
[upgrade/config] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
[preflight] Running pre-flight checks.
[preflight] Some fatal errors occurred:
[ERROR CoreDNSUnsupportedPlugins]: there are unsupported plugins in the CoreDNS Corefile
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher
执行升级命令 注意升级的版本需要和kubeadm版本一致
kubeadm upgrade apply v1.18.0
提示安装完成
再次执行 kubeadm upgrade plan 可以看到版本已经升级到1.18.0
升级过程中也会替换证书
注意一下操作需要分别在master节点和node节点执行
apt-get update
apt-get install -y --allow-change-held-packages kubelet=1.18.0-00 kubectl=1.18.0-00
重启kubelet
systemctl daemon-reload
systemctl restart kubelet
再次查看集群节点状态 kubectl get nodes -o wide