자격증/CKA

[CKA] Node 정보 수집

후드리챱챱 2023. 3. 26. 13:14
반응형

[문제1]

* Check Ready Nodes

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

 

[풀이]

ready 상태가 있는 node 확인

# kubectl get nodes
# kubectl get nodes | grep -i -w ready
master.example.com   Ready    control-plane   122d   v1.25.4
node1.example.com    Ready    <none>          122d   v1.25.4
node2.example.com    Ready    <none>          122d   v1.25.4

 

 

ready 상태인 노드 중 NoSchedule taint를 포함하는 노드인지 확인

(문제 의도는 NoSchedule이 포함되어 있으면 Ready 상태로 카운트하지 말라는 뜻)

kubectl describe node master.example.com | grep -i NoSchedule
Taints:             node-role.kubernetes.io/control-plane:NoSchedule

# kubectl describe node node1.example.com | grep -i NoSchedule
# kubectl describe node node1.example.com | grep -i taints
Taints:             <none>

# kubectl describe node node2.example.com | grep -i NoSchedule
# kubectl describe node node2.example.com | grep -i taints
Taints:             <none>

 

ready 상태인 노드 중 NoSchedule taint를 포함하는 노드 개수는 2개니깐 /var/CKA2022/RN0001 파일에 2 추가

# echo "2" > /var/CKA2022/RN0001

 

[문제2]

* Count the Number of Nodes That Are Ready to Run Normal Workloads 

- 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

 

[풀이]

# kubectl get nodes | grep -iw ready | wc -l > /var/CKA2022/NODE-Count
# cat /var/CKA2022/NODE-Count

 

 

[참고]

- 유투브 따배씨

반응형