kubeadm升级k8s_remote version is much newer v1



可以看到我们的版本可以升级到v1.24.4


### 显示版本差异



kubeadm upgrade diff 1.24.4

[upgrade/diff] Reading configuration from the cluster…
[upgrade/diff] FYI: You can look at this config file with ‘kubectl -n kube-system get cm kubeadm-config -o yaml’
— /etc/kubernetes/manifests/kube-apiserver.yaml
+++ new manifest
@@ -40,7 +40,7 @@
- --service-cluster-ip-range=10.96.0.0/12
- --tls-cert-file=/etc/kubernetes/pki/apiserver.crt
- --tls-private-key-file=/etc/kubernetes/pki/apiserver.key

  • image: registry.aliyuncs.com/google_containers/kube-apiserver:v1.24.1
  • image: registry.aliyuncs.com/google_containers/kube-apiserver:1.24.4
    imagePullPolicy: IfNotPresent
    livenessProbe:
    failureThreshold: 8
    — /etc/kubernetes/manifests/kube-controller-manager.yaml
    +++ new manifest
    @@ -28,7 +28,7 @@
    • –service-account-private-key-file=/etc/kubernetes/pki/sa.key
    • –service-cluster-ip-range=10.96.0.0/12
    • –use-service-account-credentials=true
  • image: registry.aliyuncs.com/google_containers/kube-controller-manager:v1.24.1
  • image: registry.aliyuncs.com/google_containers/kube-controller-manager:1.24.4
    imagePullPolicy: IfNotPresent
    livenessProbe:
    failureThreshold: 8
    — /etc/kubernetes/manifests/kube-scheduler.yaml
    +++ new manifest
    @@ -16,7 +16,7 @@
    • –bind-address=127.0.0.1
    • –kubeconfig=/etc/kubernetes/scheduler.conf
    • –leader-elect=true
  • image: registry.aliyuncs.com/google_containers/kube-scheduler:v1.24.1
  • image: registry.aliyuncs.com/google_containers/kube-scheduler:1.24.4
    imagePullPolicy: IfNotPresent
    livenessProbe:
    failureThreshold: 8

### 查看kubeadm版本



apt-cache madison kubeadm

kubeadm | 1.25.0-00 | https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main amd64 Packages
kubeadm | 1.24.4-00 | https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main amd64 Packages


可以看到我们最新的版本时1.25.0以及1.24.4


### 升级


升级kubeadm



sudo apt-get install kubeadm=1.24.4-00


将 Kubernetes 集群升级到指定版本



sudo kubeadm upgrade apply 1.24.4


### 升级master节点


开启调度保护



kubectl cordon master1

node/master1 cordoned

kubectl get node

NAME STATUS ROLES AGE VERSION
master1 Ready,SchedulingDisabled control-plane 145m v1.24.1
node1 Ready 121m v1.24.1
node2 Ready 108m v1.24.1

排空节点

kubectl drain master1 --ignore-daemonsets

node/master1 already cordoned
WARNING: ignoring DaemonSet-managed Pods: kube-flannel/kube-flannel-ds-8lfc4, kube-system/kube-proxy-km8gx
evicting pod kube-system/coredns-74586cf9b6-fq7gg
evicting pod kube-system/coredns-74586cf9b6-2pk2p
pod/coredns-74586cf9b6-fq7gg evicted
pod/coredns-74586cf9b6-2pk2p evicted
node/master1 drained


更新节点配置



sudo kubeadm upgrade node


升级kublet组件



sudo apt-get install -y kubelet=1.24.4-00 kubectl=1.24.4-00


取消调度保护



kubectl uncordon master1

kubectl get node

NAME STATUS ROLES AGE VERSION
master1 Ready control-plane 149m v1.24.4
node1 Ready 125m v1.24.1
node2 Ready 113m v1.24.1


### 升级node节点


开启调度保护(master节点执行)



kubectl cordon node1

node/node1 cordoned

kubectl get node

NAME STATUS ROLES AGE VERSION
master1 Ready control-plane 151m v1.24.4
node1 Ready,SchedulingDisabled 127m v1.24.1
node2 Ready 115m v1.24.1

排空节点

kubectl drain node1 --ignore-daemonsets

node/node1 already cordoned
WARNING: ignoring DaemonSet-managed Pods: kube-flannel/kube-flannel-ds-q8dpb, kube-system/kube-proxy-g7mbw
evicting pod kube-system/coredns-74586cf9b6-782sb
evicting pod default/myhello-rc-bxlbg
evicting pod default/myhello-rc-792dl
evicting pod default/myhello-rc-vxz47
pod/myhello-rc-vxz47 evicted
pod/myhello-rc-792dl evicted
pod/myhello-rc-bxlbg evicted
pod/coredns-74586cf9b6-782sb evicted
node/node1 drained

可以看到所有容器均运行到node2节点了

kubectl get pod -o wide

NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
myhello-rc-2bmwh 1/1 Running 0 22s 10.244.4.7 node2
myhello-rc-bmln7 1/1 Running 0 22s 10.244.4.9 node2
myhello-rc-kjftb 1/1 Running 0 70m 10.244.4.3 node2
myhello-rc-pk6vc 1/1 Running 0 22s 10.244.4.8 node2
myhello-rc-wdvt6 1/1 Running 0 70m 10.244.4.2 node2


升级kublet组件(node节点执行)



sudo apt-get install -y kubelet=1.24.4-00 kubectl=1.24.4-00


更新节点配置(node节点执行)



sudo kubeadm upgrade node


取消调度保护(master节点执行)



kubectl uncordon node1

kubectl get node

NAME STATUS ROLES AGE VERSION
master1 Ready control-plane 149m v1.24.4
node1 Ready 125m v1.24.1
node2 Ready 113m v1.24.1


### 升级完成

你可能感兴趣的:(kubernetes,容器,云原生)