반응형
2023.05.20
★ Cluster 버전 확인
-> v1.25.0
controlplane ~ ➜ kubectl get nodes
NAME STATUS ROLES AGE VERSION
controlplane Ready control-plane 116m v1.25.0
node01 Ready <none> 116m v1.25.0
controlplane ~ ➜
★ Worker node인 node는 어떤 노드인가요 ?
-> Taints 가 없으니 다 Worker node
controlplane ~ ➜ kubectl describe nodes controlplane | grep Taints
Taints: <none>
controlplane ~ ➜ kubectl describe nodes node01 | grep Taints
Taints: <none>
★ deploy되는 pods는 어떤 node에 올라가나요 ?
-> node01, controlplane
controlplane ~ ➜ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
blue-5db6db69f7-94bd2 1/1 Running 0 14m 10.244.1.4 node01 <none> <none>
blue-5db6db69f7-d4ckd 1/1 Running 0 14m 10.244.1.2 node01 <none> <none>
blue-5db6db69f7-fgrvp 1/1 Running 0 14m 10.244.1.3 node01 <none> <none>
blue-5db6db69f7-fkvdv 1/1 Running 0 14m 10.244.0.5 controlplane <none> <none>
blue-5db6db69f7-kcnkl 1/1 Running 0 14m 10.244.0.4 controlplane <none> <none>
★ 클러스터를 업그레이드하는 작업을 수행해야 합니다. 애플리케이션에 접속하는 사용자에게 영향을 미치지 않아야 하며 새 VM을 프로비저닝할 수 없습니다. 클러스터를 업그레이드하기 위해 어떤 방법을 사용하시겠습니까?
-> Worker node를 다른 노드로 이동하면서 한 번에 한 노드씩 업그레이드
★ 현재 쿠버네티스의 안정적인 최신 버전은 무엇인가요?
-> v1.27.2
controlplane ~ ➜ 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.0
[upgrade/versions] kubeadm version: v1.25.0
I0519 23:10:12.713401 17274 version.go:256] remote version is much newer: v1.27.2; falling back to: stable-1.25
[upgrade/versions] Target version: v1.25.10
[upgrade/versions] Latest version in the v1.25 series: v1.25.10
★ 현재 버전의 kubeadm 도구가 설치된 상태에서 업그레이드할 수 있는 최신 버전은 무엇인가요?
-> v1.25.10
controlplane ~ ➜ 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.0
[upgrade/versions] kubeadm version: v1.25.0
I0519 23:10:12.713401 17274 version.go:256] remote version is much newer: v1.27.2; falling back to: stable-1.25
[upgrade/versions] Target version: v1.25.10
[upgrade/versions] Latest version in the v1.25 series: v1.25.10
Components that must be upgraded manually after you have upgraded the control plane with 'kubeadm upgrade apply':
COMPONENT CURRENT TARGET
kubelet 2 x v1.25.0 v1.25.10
Upgrade to the latest version in the v1.25 series:
COMPONENT CURRENT TARGET
kube-apiserver v1.25.0 v1.25.10
kube-controller-manager v1.25.0 v1.25.10
kube-scheduler v1.25.0 v1.25.10
kube-proxy v1.25.0 v1.25.10
CoreDNS v1.9.3 v1.9.3
etcd 3.5.4-0 3.5.4-0
You can now apply the upgrade by executing the following command:
kubeadm upgrade apply v1.25.10
Note: Before you can perform this upgrade, you have to update kubeadm to v1.25.10.
★ controlplane node를 업그레이드할 것입니다. 컨트롤 플레인 노드에서 워크로드를 비우고 예약 불가능으로 설정해주세요.
controlplane ~ ✖ kubectl drain controlplane --ignore-daemonsets
node/controlplane already cordoned
Warning: ignoring DaemonSet-managed Pods: kube-flannel/kube-flannel-ds-qljgv, kube-system/kube-proxy-xkrtl
evicting pod kube-system/coredns-565d847f94-8ldgw
evicting pod default/blue-5db6db69f7-jhn5p
evicting pod default/blue-5db6db69f7-6pkjn
evicting pod kube-system/coredns-565d847f94-2bbdc
pod/blue-5db6db69f7-jhn5p evicted
pod/blue-5db6db69f7-6pkjn evicted
pod/coredns-565d847f94-2bbdc evicted
pod/coredns-565d847f94-8ldgw evicted
node/controlplane drained
controlplane ~ ➜
★ Controlplane node 업그레이드
controlplane ~ ➜ apt update
Get:1 https://packages.cloud.google.com/apt kubernetes-xenial InRelease [8,993 B]
Hit:2 https://download.docker.com/linux/ubuntu focal InRelease
...
controlplane ~ ➜ apt-get install kubeadm=1.26.0-00
Reading package lists... Done
Building dependency tree
Reading state information... Done
...
controlplane ~ ➜ kubeadm upgrade apply v1.26.0
[upgrade/config] Making sure the configuration is correct:
[upgrade/config] Reading configuration from the cluster...
...
controlplane ~ ➜ kubectl get nodes
NAME STATUS ROLES AGE VERSION
controlplane Ready,SchedulingDisabled control-plane 85m v1.26.0
node01 Ready <none> 84m v1.25.0
controlplane ~ ➜
★ Controlplane node에서 예약 가능으로 설정하세요.
controlplane ~ ✖ kubectl uncordon controlplane
node/controlplane uncordoned
★ node01를 업그레이드할 것입니다. 워크로드를 비우고 예약 불가능으로 설정해주세요.
-> drain하게되면 node에 있던 pod들은 이동한다.
controlplane ~ ➜ kubectl drain node01 --ignore-daemonsets
node/node01 cordoned
Warning: ignoring DaemonSet-managed Pods: kube-flannel/kube-flannel-ds-2stnt, kube-system/kube-proxy-n5hmd
evicting pod kube-system/coredns-787d4945fb-lqjjv
evicting pod default/blue-5db6db69f7-225hb
evicting pod default/blue-5db6db69f7-c7ptb
evicting pod default/blue-5db6db69f7-gkbz4
evicting pod default/blue-5db6db69f7-r4rvt
evicting pod default/blue-5db6db69f7-tv2p9
evicting pod kube-system/coredns-787d4945fb-kr6xw
pod/blue-5db6db69f7-gkbz4 evicted
pod/blue-5db6db69f7-tv2p9 evicted
pod/blue-5db6db69f7-r4rvt evicted
pod/blue-5db6db69f7-225hb evicted
pod/blue-5db6db69f7-c7ptb evicted
pod/coredns-787d4945fb-kr6xw evicted
pod/coredns-787d4945fb-lqjjv evicted
node/node01 drained
controlplane ~ ➜ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
blue-5db6db69f7-5sld2 1/1 Running 0 17s 10.244.0.7 controlplane <none> <none>
blue-5db6db69f7-9c4w2 1/1 Running 0 17s 10.244.0.12 controlplane <none> <none>
blue-5db6db69f7-9mhbr 1/1 Running 0 17s 10.244.0.9 controlplane <none> <none>
blue-5db6db69f7-j7tgx 1/1 Running 0 17s 10.244.0.11 controlplane <none> <none>
blue-5db6db69f7-p98g5 1/1 Running 0 17s 10.244.0.10 controlplane <none> <none>
controlplane ~ ➜
★ node01 업그레이드
controlplane ~ ➜ ssh node01
root@node01 ~ ➜ apt-get update
Get:2 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:3 https://download.docker.com/linux/ubuntu focal InRelease [57.7 kB]
Get:1 https://packages.cloud.google.com/apt kubernetes-xenial InRelease [8993 B]
...
root@node01 ~ ➜ apt-get install kubeadm=1.26.0-00
Reading package lists... Done
Building dependency tree
Reading state information... Done
...
oot@node01 ~ ➜ 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
...
root@node01 ~ ➜ apt-get install kubelet=1.26.0-00
Reading package lists... Done
Building dependency tree
Reading state information... Done
...
root@node01 ~ ➜ systemctl daemon-reload
root@node01 ~ ➜ systemctl restart kubelet.service
controlplane ~ ➜ kubectl get node
NAME STATUS ROLES AGE VERSION
controlplane Ready control-plane 118m v1.26.0
node01 NotReady,SchedulingDisabled <none> 117m v1.26.0
controlplane ~ ➜
★ node01 노드를 예약 가능으로 설정하세요.
controlplane ~ ➜ kubectl uncordon node01
node/node01 uncordoned
반응형
'Kubernetes > Kubernetes Exam' 카테고리의 다른 글
[K8s] CKA 취득 연습문제#6 (csr approve, reject) (0) | 2023.05.30 |
---|---|
[K8s] CKA 취득 연습문제#5 (etcd, apiserver 인증서) (0) | 2023.05.29 |
[K8s] CKA 취득 연습문제#4 (etcd backup, recovery) (0) | 2023.05.24 |
[K8s] CKA 취득 연습문제#3 (etcd backup, snapshot) (0) | 2023.05.20 |
[K8s] CKA 취득 연습문제#1 (cordor, drain) (0) | 2023.05.17 |