블록체인
블록체인

쿠버네티스 버전 업그레이드 방법

목차

쿠버네티스 버전 업그레이드 순서(마스터 노드)

1. 업그레이드 계획 수립

1.25.0에서 1.25.3으로 업그레이드 해보자.
# 현재 버전을 확인해보자. 1.25.0으로 나온다. [root@m-k8s log]# kubectl get nodes NAME STATUS ROLES AGE VERSION m-k8s Ready control-plane 3d1h v1.25.0 w1-k8s Ready <none> 3d1h v1.25.0 w2-k8s Ready <none> 3d1h v1.25.0 w3-k8s Ready <none> 3d1h v1.25.0 # 가장 최신 버전을 확인해보면 1.25.3이라고 나온다. 이 버전으로 업그레이드 해보자. [root@m-k8s log]# 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 -o yaml' [preflight] Running pre-flight checks. [upgrade] Running cluster health checks [upgrade] Fetching available versions to upgrade to [upgrade/versions] Cluster version: v1.25.3 [upgrade/versions] kubeadm version: v1.25.0 [upgrade/versions] Target version: v1.25.3 [upgrade/versions] Latest version in the v1.25 series: v1.25.3
Shell
복사

2. kubeadm업그레이드

kubeadm를 1.25.3으로 업그레이드 한다.
# 업그레이드 시도 시 kubeadm 버전이 1.25.0으로 업그레이드 하려는 버전(1.25.3)보다 낮기때문에 에러가 난다. [root@m-k8s log]# kubeadm upgrade apply 1.25.3 [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' [preflight] Running pre-flight checks. [upgrade] Running cluster health checks [upgrade/version] You have chosen to change the cluster version to "v1.25.3" [upgrade/versions] Cluster version: v1.25.3 [upgrade/versions] kubeadm version: v1.25.0 [upgrade/version] FATAL: the --version argument is invalid due to these errors: - Specified version to upgrade to "v1.25.3" is higher than the kubeadm version "v1.25.0". Upgrade kubeadm first using the tool you used to install kubeadm Can be bypassed if you pass the --force flag To see the stack trace of this error execute with --v=5 or higher # kubeadm 버전을 1.25.3으로 업그레이드 해주자. [root@m-k8s log]# yum upgrade kubeadm-1.25.3 -y # kubeadm이 1.25.3버전으로 업그레이드 되었다. [root@m-k8s log]# kubeadm version kubeadm version: &version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.3", GitCommit:"434bfd82814af038ad94d62ebe59b133fcb50506", GitTreeState:"clean", BuildDate:"2022-10-12T10:55:36Z", GoVersion:"go1.19.2", Compiler:"gc", Platform:"linux/amd64"} # 업그레이드가 정상적으로 된다. [root@m-k8s log]# kubeadm upgrade apply 1.25.3 [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' [preflight] Running pre-flight checks. [upgrade] Running cluster health checks [upgrade/version] You have chosen to change the cluster version to "v1.25.3" [upgrade/versions] Cluster version: v1.25.3 [upgrade/versions] kubeadm version: v1.25.3 [upgrade] Are you sure you want to proceed? [y/N]: y [upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.25.3". Enjoy! [upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven't already done so. # 서버 버전이 1.25.3으로 업그레이드 된 것이 확인된다. [root@m-k8s log]# kubectl version WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short. Use --output=yaml|json to get the full version. Client Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.0", GitCommit:"a866cbe2e5bbaa01cfd5e969aa3e033f3282a8a2", GitTreeState:"clean", BuildDate:"2022-08-23T17:44:59Z", GoVersion:"go1.19", Compiler:"gc", Platform:"linux/amd64"} Kustomize Version: v4.5.7 Server Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.3", GitCommit:"434bfd82814af038ad94d62ebe59b133fcb50506", GitTreeState:"clean", BuildDate:"2022-10-12T10:49:09Z", GoVersion:"go1.19.2", Compiler:"gc", Platform:"linux/amd64"}
Shell
복사

3. kubelet 업그레이드

# kubelet 버전이 1.25.0으로 나온다. [root@m-k8s log]# kubelet --version Kubernetes v1.25.0 # kubelet을 1.25.3으로 업그레이드 한다. [root@m-k8s log]# yum upgrade kubelet-1.25.3 -y # kubelet을 재시작한다. [root@m-k8s log]# systemctl restart kubelet Warning: kubelet.service changed on disk. Run 'systemctl daemon-reload' to reload units. [root@m-k8s log]# systemctl daemon-reload
Shell
복사

4. 업그레이드 확인

# 현재 버전을 확인해보면 업그레이드 된 1.25.3으로 나온다. [root@m-k8s log]# kubectl get nodes NAME STATUS ROLES AGE VERSION m-k8s Ready control-plane 3d1h v1.25.3 w1-k8s Ready <none> 3d1h v1.25.0 w2-k8s Ready <none> 3d1h v1.25.0 w3-k8s Ready <none> 3d1h v1.25.0
Shell
복사

쿠버네티스 버전 업그레이드 순서(워커 노드)

2. kubeadm업그레이드

kubeadm를 1.25.3으로 업그레이드 한다.
# kubeadm 버전을 1.25.3으로 업그레이드 해주자. [root@w1-k8s log]# yum upgrade kubeadm-1.25.3 -y # kubeadm이 1.25.3버전으로 업그레이드 되었다. [root@w1-k8s log]# kubeadm version kubeadm version: &version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.3", GitCommit:"434bfd82814af038ad94d62ebe59b133fcb50506", GitTreeState:"clean", BuildDate:"2022-10-12T10:55:36Z", GoVersion:"go1.19.2", Compiler:"gc", Platform:"linux/amd64"} # 업그레이드가 정상적으로 된다. [root@w1-k8s ~]# 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' [preflight] Running pre-flight checks [preflight] Skipping prepull. Not a control plane node. [upgrade] Skipping phase. Not a control plane node. [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. # 서버 버전이 1.25.3으로 업그레이드 된 것이 확인된다.??????????????????????????? [root@w1-k8s ~]# kubectl version WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short. Use --output=yaml|json to get the full version. Client Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.0", GitCommit:"a866cbe2e5bbaa01cfd5e969aa3e033f3282a8a2", GitTreeState:"clean", BuildDate:"2022-08-23T17:44:59Z", GoVersion:"go1.19", Compiler:"gc", Platform:"linux/amd64"} Kustomize Version: v4.5.7 The connection to the server localhost:8080 was refused - did you specify the right host or port?
Shell
복사

3. kubelet 업그레이드

# kubelet 버전이 1.25.0으로 나온다. [root@w1-k8s log]# kubelet --version Kubernetes v1.25.0 # kubelet을 1.25.3으로 업그레이드 한다.(나머지 워커노드 들에서도 똑같이 업그레이드 한다.) [root@w1-k8s log]# yum upgrade kubelet-1.25.3 -y [root@w2-k8s ~]# yum upgrade kubelet-1.25.3 -y [root@w3-k8s ~]# yum upgrade kubelet-1.25.3 -y # kubelet을 재시작한다.(나머지 워커노드 들에서도 똑같이 업그레이드 한다.) [root@w1-k8s log]# systemctl restart kubelet Warning: kubelet.service changed on disk. Run 'systemctl daemon-reload' to reload units. [root@w1-k8s log]# systemctl daemon-reload [root@w2-k8s log]# systemctl restart kubelet Warning: kubelet.service changed on disk. Run 'systemctl daemon-reload' to reload units. [root@w2-k8s log]# systemctl daemon-reload [root@w3-k8s log]# systemctl restart kubelet Warning: kubelet.service changed on disk. Run 'systemctl daemon-reload' to reload units. [root@w3-k8s log]# systemctl daemon-reload
Shell
복사

4. 업그레이드 확인

# 현재 버전을 확인해보면 업그레이드 된 1.25.3으로 나온다. [root@m-k8s log]# kubectl get nodes NAME STATUS ROLES AGE VERSION m-k8s Ready control-plane 3d2h v1.25.3 w1-k8s Ready <none> 3d1h v1.25.3 w2-k8s Ready <none> 3d1h v1.25.3 w3-k8s Ready <none> 3d1h v1.25.3
Shell
복사