본문 바로가기
Compute/kubernetis

[따배씨] 9. Node 관리 / drain & uncordon / CKA 시험 문제 학습

by 조청유곽 2025. 1. 30.
반응형

이 포스팅은 아래의 유튜브 채널 "따배"를 따라서 학습한 내용입니다.  

 

 

 

[관련 이론]


 

 

[Precondition]

(1) 테스트 환경

(1.1) Rocky Linux Cluster 

: 직접 구성

[root@k8s-master ~]# k get nodes -o wide
NAME         STATUS   ROLES           AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                            KERNEL-VERSION                  CONTAINER-RUNTIME
k8s-master   Ready    control-plane   30d   v1.27.2   192.168.56.30   <none>        Rocky Linux 8.10 (Green Obsidian)   4.18.0-553.33.1.el8_10.x86_64   containerd://1.6.32
k8s-node1    Ready    <none>          30d   v1.27.2   192.168.56.31   <none>        Rocky Linux 8.8 (Green Obsidian)    4.18.0-477.10.1.el8_8.x86_64    containerd://1.6.21
k8s-node2    Ready    <none>          30d   v1.27.2   192.168.56.32   <none>        Rocky Linux 8.8 (Green Obsidian)    4.18.0-477.10.1.el8_8.x86_64    containerd://1.6.21
[root@k8s-master ~]#

 

(1.2) Ubuntu Cluster 

: kodekloud 테스트 환경 활용

controlplane ~ ➜  kubectl get nodes -o wide
NAME           STATUS   ROLES           AGE     VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION   CONTAINER-RUNTIME
controlplane   Ready    control-plane   9m6s    v1.31.0   192.6.94.6    <none>        Ubuntu 22.04.4 LTS   5.4.0-1106-gcp   containerd://1.6.26
node01         Ready    <none>          8m31s   v1.31.0   192.6.94.9    <none>        Ubuntu 22.04.4 LTS   5.4.0-1106-gcp   containerd://1.6.26

https://learn.kodekloud.com/user/courses/udemy-labs-certified-kubernetes-administrator-with-practice-tests

 

 

(2) 사전 필요 설정 

: N/A


 

 

[Question]

작업 클러스터 : node01

Set the node named node01 as unavailable and reschedule all the pods running on it.

 

 

[Solve]

(1) node 리스트 및 pod가 배포되어 있는 node 확인 

controlplane ~ ➜  k get nodes 
controlplane ~ ➜  k get pods -o wide

 

 

(2) node01에 pod가 배포되지 않도록 조치(uncordon) 후 reschedule을(drain) 실행한다. 

controlplane ~ ➜  k cordon node01
node/node01 cordoned

controlplane ~ ➜  k get nodes 
NAME           STATUS                     ROLES           AGE     VERSION
controlplane   Ready                      control-plane   8m5s    v1.31.0
node01         Ready,SchedulingDisabled   <none>          7m24s   v1.31.0

controlplane ~ ➜  k drain node01 --ignore-daemonsets --delete-emptydir-data 
node/node01 already cordoned
Warning: ignoring DaemonSet-managed Pods: kube-system/canal-j8gx9, kube-system/kube-proxy-4mgf4
evicting pod default/test-556b4dcc6c-sc2gt
evicting pod default/test-556b4dcc6c-29smp
evicting pod default/test-556b4dcc6c-q9q5d
pod/test-556b4dcc6c-29smp evicted
pod/test-556b4dcc6c-q9q5d evicted
pod/test-556b4dcc6c-sc2gt evicted
node/node01 drained

 

 

(3) reschedule 후 pod 배포 상태를 확인 

 

 

(4) node01에 pod가 배포될 수 있도록 uncordon

controlplane ~ ➜  k uncordon node01
node/node01 uncordoned


 

 

[사용 커맨드 정리]

k cordon node01

k drain node01 --ignore-daemonsets --delete-emptydir-data

k get nodes

k uncordon node01

k get pods -o wide

반응형