Kubernetes-集群升级

2021-06-01 12:02

阅读:709

标签:tar   image   role   can   install   chosen   RKE   rest   bec   

  • 集群版本V1.18.2
root@k8s:~# kubectl get nodes
NAME    STATUS   ROLES    AGE   VERSION
k8s     Ready    master   20d   v1.18.2
node1   Ready    worker   20d   v1.18.2
node2   Ready    worker   20d   v1.18.2
node3   Ready    worker   20d   v1.18.2
  • 将master标记为不可调度
trnuser@k8s:~$ kubectl cordon k8s
node/k8s cordoned
trnuser@k8s:~$ kubectl get nodes
NAME    STATUS                     ROLES    AGE   VERSION
k8s     Ready,SchedulingDisabled   master   20d   v1.18.2
node1   Ready                      worker   20d   v1.18.2
node2   Ready                      worker   20d   v1.18.2
node3   Ready                      worker   20d   v1.18.2
trnuser@k8s:~$
  • 安装指定版本的kubeadm,kubelet,kubectl
sudo apt install kubeadm=1.19.7-00 kubectl=1.19.7-00 kubelet=1.19.7-00 -y
  • 重启kubelet服务
systemctl restart kubelet
  • 应用升级
trnuser@k8s:~$ sudo kubeadm upgrade apply v1.19.7
[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.
[upgrade] Running cluster health checks
[upgrade/version] You have chosen to change the cluster version to "v1.19.7"
[upgrade/versions] Cluster version: v1.18.2
[upgrade/versions] kubeadm version: v1.19.7
[upgrade/confirm] Are you sure you want to proceed with the upgrade? [y/N]: y
[upgrade/prepull] Pulling images required for setting up a Kubernetes cluster
[upgrade/prepull] This might take a minute or two, depending on the speed of your internet connection
[upgrade/prepull] You can also perform this action in beforehand using ‘kubeadm config images pull‘
...
  • 完成升级并验证
trnuser@k8s:~$ kubectl get nodes
NAME    STATUS                     ROLES    AGE   VERSION
k8s     Ready,SchedulingDisabled   master   20d   v1.19.7
node1   Ready                      worker   20d   v1.18.2
node2   Ready                      worker   20d   v1.18.2
node3   Ready                      worker   20d   v1.18.2
  • 恢复调度
trnuser@k8s:~$ kubectl uncordon k8s
node/k8s uncordoned
trnuser@k8s:~$ kubectl get nodes
NAME    STATUS   ROLES    AGE   VERSION
k8s     Ready    master   20d   v1.19.7
node1   Ready    worker   20d   v1.18.2
node2   Ready    worker   20d   v1.18.2
node3   Ready    worker   20d   v1.18.2

Kubernetes-集群升级

标签:tar   image   role   can   install   chosen   RKE   rest   bec   

原文地址:https://www.cnblogs.com/bigdad/p/14538222.html


评论


亲,登录后才可以留言!