k8s upgrade

upgrade

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
❯ curl -O https://gh-proxy.com/https://github.com/kubernetes/kubernetes/archive/refs/tags/v1.27.16.tar.gz


❯ cd kubernetes-1.27.16
❯ make kubectl kubeadm kubelet
go version go1.22.5 linux/amd64
+++ [0813 15:12:42] Building go targets for linux/amd64
k8s.io/kubernetes/cmd/kubectl (static)
go version go1.22.5 linux/amd64
+++ [0813 15:13:28] Building go targets for linux/amd64
k8s.io/kubernetes/cmd/kubeadm (static)
go version go1.22.5 linux/amd64
+++ [0813 15:13:42] Building go targets for linux/amd64
k8s.io/kubernetes/cmd/kubelet (non-static)

./_output/local/bin/linux/amd64/kubectl version
1
2
3
4
5
6
7
8
9
10
❯ ./kubeadm  --image-repository registry.aliyuncs.com/google_containers config images list
I0813 15:17:23.993040 121529 version.go:256] remote version is much newer: v1.30.3; falling back to: stable-1.27
registry.aliyuncs.com/google_containers/kube-apiserver:v1.27.16
registry.aliyuncs.com/google_containers/kube-controller-manager:v1.27.16
registry.aliyuncs.com/google_containers/kube-scheduler:v1.27.16
registry.aliyuncs.com/google_containers/kube-proxy:v1.27.16
registry.aliyuncs.com/google_containers/pause:3.9
registry.aliyuncs.com/google_containers/etcd:3.5.12-0
registry.aliyuncs.com/google_containers/coredns:v1.10.1

中控机

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
❯ kubectl cordon k8s01
node/k8s01 cordoned
❯ kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s01 Ready,SchedulingDisabled control-plane 512d v1.26.1
k8s02 Ready control-plane 512d v1.26.1
k8s03 Ready control-plane 512d v1.26.1
k8s04 Ready <none> 507d v1.26.1
k8s05 Ready <none> 507d v1.26.1
k8s06 Ready <none> 507d v1.26.1
k8s07 Ready <none> 292d v1.26.1
k8s08 Ready <none> 291d v1.26.1
❯ kubectl drain k8s01 --ignore-daemonsets --force
node/k8s01 already cordoned
Warning: ignoring DaemonSet-managed Pods: kube-system/kube-flannel-ds-cf6kk, kube-system/kube-proxy-484d8, metallb-system/metallb-speaker-jhlsm
node/k8s01 drained

节点

1
2
3
4
5
6
7
8
9
10
11
12
[root@k8s01 ~]# kubeadm upgrade apply v1.27.16  --etcd-upgrade=false
[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 -o yaml'
W0813 15:52:13.060575 15128 utils.go:69] The recommended value for "clusterDNS" in "KubeletConfiguration" is: [10.96.0.10]; the provided value is: [121.21.0.0]
[preflight] Running pre-flight checks.
[preflight] Some fatal errors occurred:
[ERROR CoreDNSUnsupportedPlugins]: start version '' not supported
[ERROR CoreDNSMigration]: CoreDNS will not be upgraded: start version '' not supported
[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

#第一个控制面节点

[root@k8s01 ~]# kubeadm upgrade apply v1.27.16 –etcd-upgrade=false –ignore-preflight-errors=CoreDNSUnsupportedPlugins,CoreDNSMigration –v=5

。。。。

[upgrade/successful] SUCCESS! Your cluster was upgraded to “v1.27.16”. Enjoy!

[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven’t already done so.
[root@k8s01 ~]# kubelet –version
Kubernetes v1.27.16
[root@k8s01 ~]# systemctl restart kubelet
[root@k8s01 ~]# systemctl status kubelet
● kubelet.service - Kubernetes Kubelet Server
Loaded: loaded (/etc/systemd/system/kubelet.service; enabled; vendor preset: disabled)
Active: active (running) since 二 2024-08-13 18:37:34 CST; 6s ago

中控机

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
❯ kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s01 Ready,SchedulingDisabled control-plane 512d v1.27.16
k8s02 Ready control-plane 512d v1.26.1
k8s03 Ready control-plane 512d v1.26.1
k8s04 Ready <none> 507d v1.26.1
k8s05 Ready <none> 507d v1.26.1
k8s06 Ready <none> 507d v1.26.1
k8s07 Ready <none> 292d v1.26.1
k8s08 Ready <none> 292d v1.26.1
❯ kubectl uncordon k8s01
node/k8s01 uncordoned
❯ kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s01 Ready control-plane 512d v1.27.16
k8s02 Ready control-plane 512d v1.26.1
k8s03 Ready control-plane 512d v1.26.1
k8s04 Ready <none> 507d v1.26.1
k8s05 Ready <none> 507d v1.26.1
k8s06 Ready <none> 507d v1.26.1
k8s07 Ready <none> 292d v1.26.1
k8s08 Ready <none> 292d v1.26.1
❯ kubectl cordon k8s02
node/k8s02 cordoned

其他控制面板

[root@k8s02 ~]# kubeadm upgrade node
[upgrade] Reading configuration from the cluster…
[upgrade] FYI: You can look at this config file with ‘kubectl -n kube-system get cm kubeadm-config -o yaml’
W0813 18:53:19.459791 21065 utils.go:69] The recommended value for “clusterDNS” in “KubeletConfiguration” is: [10.96.0.10]; the provided value is: [121.21.0.0]
[preflight] Running pre-flight checks
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using ‘kubeadm config images pull’
[upgrade] Upgrading your Static Pod-hosted control plane instance to version “v1.27.16”…

……

[upgrade] The configuration for this node was successfully updated!
[upgrade] Now you should go ahead and upgrade the kubelet package using your package manager.

[root@k8s02 ~]# kubelet –version
Kubernetes v1.27.16
[root@k8s02 ~]# systemctl restart kubelet
[root@k8s02 ~]# systemctl status kubelet
● kubelet.service - Kubernetes Kubelet Server
Loaded: loaded (/etc/systemd/system/kubelet.service; enabled; vendor preset: disabled)
Active: active (running) since 二 2024-08-13 18:57:18 CST; 6s ago

kubeadm upgrade node
中控机 ansible
❯ ansible k8s03 -m shell -a " kubeadm upgrade node "
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
k8s03 | CHANGED | rc=0 >>
[upgrade] Reading configuration from the cluster...
[upgrade] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[preflight] Running pre-flight checks
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[upgrade] Upgrading your Static Pod-hosted control plane instance to version "v1.27.16"...
[upgrade/etcd] Upgrading to TLS for etcd
[upgrade/staticpods] Preparing for "etcd" upgrade
[upgrade/staticpods] Renewing etcd-server certificate
[upgrade/staticpods] Renewing etcd-peer certificate
[upgrade/staticpods] Renewing etcd-healthcheck-client certificate
[upgrade/staticpods] Moved new manifest to "/etc/kubernetes/manifests/etcd.yaml" and backed up old manifest to "/etc/kubernetes/tmp/kubeadm-backup-manifests-2024-08-13-19-07-56/etcd.yaml"
[upgrade/staticpods] Waiting for the kubelet to restart the component
[upgrade/staticpods] This might take a minute or longer depending on the component/version gap (timeout 5m0s)
[apiclient] Found 3 Pods for label selector component=etcd
[upgrade/staticpods] Component "etcd" upgraded successfully!
[upgrade/etcd] Waiting for etcd to become available
[upgrade/staticpods] Writing new Static Pod manifests to "/etc/kubernetes/tmp/kubeadm-upgraded-manifests666306646"
[upgrade/staticpods] Preparing for "kube-apiserver" upgrade
[upgrade/staticpods] Renewing apiserver certificate
[upgrade/staticpods] Renewing apiserver-kubelet-client certificate
[upgrade/staticpods] Renewing front-proxy-client certificate
[upgrade/staticpods] Renewing apiserver-etcd-client certificate
[upgrade/staticpods] Moved new manifest to "/etc/kubernetes/manifests/kube-apiserver.yaml" and backed up old manifest to "/etc/kubernetes/tmp/kubeadm-backup-manifests-2024-08-13-19-07-56/kube-apiserver.yaml"
[upgrade/staticpods] Waiting for the kubelet to restart the component
[upgrade/staticpods] This might take a minute or longer depending on the component/version gap (timeout 5m0s)
[apiclient] Found 3 Pods for label selector component=kube-apiserver
[upgrade/staticpods] Component "kube-apiserver" upgraded successfully!
[upgrade/staticpods] Preparing for "kube-controller-manager" upgrade
[upgrade/staticpods] Renewing controller-manager.conf certificate
[upgrade/staticpods] Moved new manifest to "/etc/kubernetes/manifests/kube-controller-manager.yaml" and backed up old manifest to "/etc/kubernetes/tmp/kubeadm-backup-manifests-2024-08-13-19-07-56/kube-controller-manager.yaml"
[upgrade/staticpods] Waiting for the kubelet to restart the component
[upgrade/staticpods] This might take a minute or longer depending on the component/version gap (timeout 5m0s)
[apiclient] Found 3 Pods for label selector component=kube-controller-manager
[upgrade/staticpods] Component "kube-controller-manager" upgraded successfully!
[upgrade/staticpods] Preparing for "kube-scheduler" upgrade
[upgrade/staticpods] Renewing scheduler.conf certificate
[upgrade/staticpods] Moved new manifest to "/etc/kubernetes/manifests/kube-scheduler.yaml" and backed up old manifest to "/etc/kubernetes/tmp/kubeadm-backup-manifests-2024-08-13-19-07-56/kube-scheduler.yaml"
[upgrade/staticpods] Waiting for the kubelet to restart the component
[upgrade/staticpods] This might take a minute or longer depending on the component/version gap (timeout 5m0s)
[apiclient] Found 3 Pods for label selector component=kube-scheduler
[upgrade/staticpods] Component "kube-scheduler" upgraded successfully!
[upgrade] The control plane instance for this node was successfully updated!
[upgrade] Backing up kubelet config file to /etc/kubernetes/tmp/kubeadm-kubelet-config3865846150/config.yaml
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[upgrade] The configuration for this node was successfully updated!
[upgrade] Now you should go ahead and upgrade the kubelet package using your package manager.W0813 19:07:43.475203   20009 utils.go:69] The recommended value for "clusterDNS" in "KubeletConfiguration" is: [10.96.0.10]; the provided value is: [121.21.0.0]
  

升级

https://v1-27.docs.kubernetes.io/zh-cn/docs/tasks/administer-cluster/kubeadm/kubeadm-upgrade/

https://v1-27.docs.kubernetes.io/zh-cn/docs/tasks/administer-cluster/kubeadm/upgrading-linux-nodes/

点击打赏
文章目录
  1. 1. upgrade
    1. 1.1. 升级
载入天数...载入时分秒... ,