본문 바로가기
Compute/kubernetis

[따배씨] 10. Node 정보 수집 / tainted NoSchedule node / CKA 시험 문제 학습

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

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

 

 

 

 

[관련 이론]

 

 

테인트(Taints)와 톨러레이션(Tolerations)

노드 어피니티는 노드 셋을 (기본 설정 또는 어려운 요구 사항으로) 끌어들이는 파드의 속성이다. 
테인트 는 그 반대로, 노드가 파드 셋을 제외시킬 수 있다.

톨러레이션은 파드에 적용된다. 
톨러레이션을 통해 스케줄러는 그와 일치하는 테인트가 있는 파드를 스케줄할 수 있다. 
톨러레이션은 스케줄을 허용하지만 보장하지는 않는다. 
스케줄러는 그 기능의 일부로서 다른 매개변수를 고려한다.

테인트와 톨러레이션은 함께 작동하여 파드가 부적절한 노드에 스케줄되지 않게 한다. 
하나 이상의 테인트가 노드에 적용되는데, 이것은 노드가 테인트를 용인하지 않는 파드를 수용해서는 안 된다는 것을 나타낸다.

 


 

 

[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#1]

Check to see how many nodes are ready (not including nodes tainted NoSchedule) and write the number to /var/CKA2022/RN0001

 

 

[Solve]

(1) 문제에서 요구하는 노드를 찾는다.
: 상태가 ready이면서 taints에 NoSchedule이 아닌 node의 개수를 찾는다.  

controlplane ~ ➜  k get nodes
NAME           STATUS   ROLES           AGE   VERSION
controlplane   Ready    control-plane   24m   v1.31.0
node01         Ready    <none>          23m   v1.31.0

controlplane ~ ➜  
controlplane ~ ➜  k describe nodes | grep -i noschedule

 

 

(2) 개수를 요구하는 경로에 파일로 저장 

 


 

 

[사용 커맨드 정리]

k get nodes

k describe nodes | grep -i noshedule

k describe nodes

echo 2 > var/CKA2022/RN0001

cat /var/CKA2022/RN0001


 

 

[Question#2]

Determine how many nodes in the cluster are ready to run normal workloads (i.e. workloads that do not gave any special tolerations).
Output this number to the file /var/CKA2022/NODE-Count

 

 

[Solve]

(1) ready이면서 taints 설정이 없는 node를 확인한다. 

: node에 taints가 설정된 경우 pod의 toleration을 확인하게 된다. 

: 유튜브 강의와 시험 환경이 다른 상태에서 문제 풀이를 해보기 위해서 node01을 cordon 후 테스트 진행. 

  -> cordon한 node는 taints에 NoSchedule 상태가 된다. 

 

 

(2) 확인한 node의 개수를 /var/CKA2022/NODE-Count로 저장  

 


 

 

[사용 커맨드 정리]

k get nodes 

k describe nodes | grep -i taint

echo 1 > /var/CKA2022/NODE-Count

cat /var/CKA2022/NODE-Count

 

반응형