본문 바로가기
IT 기술/k8s

[cka] Taints and Tolerations

by Geunny 2024. 6. 8.
반응형

 

1. How many nodes exist on the system?
Including the controlplane node.

 

$ controlplane ~ ➜  k get nodes
NAME           STATUS   ROLES           AGE     VERSION
controlplane   Ready    control-plane   6m18s   v1.29.0
node01         Ready    <none>          5m38s   v1.29.0

 

answer : 2

 

2. Do any taints exist on node01 node?

controlplane ~ ➜  k describe node node01 | grep -i taints
Taints:             <none>

 

answer : No

 

3.  Create a taint on node01 with key of spray, value of mortein and effect of NoSchedule

 

taint 사용법

# kubectl taint nodes <node-name> <key>=<value>:<effect>
$ controlplane ~ ✖ kubectl taint nodes node01 spray=mortein:NoSchedule
node/node01 tainted

 

4. Create a new pod with the nginx image and pod name as mosquito.

$ controlplane ~ ✖ k run mosquito --image=nginx
pod/mosquito created

 

 

5.  What is the state of the POD?

$ controlplane ~ ➜  k get pods
NAME       READY   STATUS    RESTARTS   AGE
mosquito   0/1     Pending   0          33s

 

answer : Pending

 

6. Why do you think the pod is in a pending state?

node01 에 taint를 걸어두엇기 때문에 파드에 taint에 대한 정보가 없으면 해당 pod는 노드에 schedule 될수 없다.

 

answer : Pod mosquito cannpt tolerate tain Mortein

 

 

7.  Create another pod named bee with the nginx image, which has a toleration set to the taint mortein.

 

https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/

 

Taints and Tolerations

Node affinity is a property of Pods that attracts them to a set of nodes (either as a preference or a hard requirement). Taints are the opposite -- they allow a node to repel a set of pods. Tolerations are applied to pods. Tolerations allow the scheduler t

kubernetes.io

 

apiVersion: v1
kind: Pod
metadata:
  name: bee
spec:
  containers:
  - name: nginx
    image: nginx
  tolerations:
  - key: "spray"
    operator: "Equal"
    value: "mortein"
    effect: "NoSchedule"

 

8. Notice the bee pod was scheduled on node node01 despite the taint.

9.  Do you see any taints on controlplane node?

$ controlplane ~ ➜ k describe node controlplane | grep -i taints 
Taints: node-role.kubernetes.io/control-plane:NoSchedule

 

answer : Yes :NoSchedule

 

10. Remove the taint on controlplane, which currently has the taint effect of NoSchedule.

tiant effect 값에 마이너스( '-' ) 키워드를 통해 untainte 를 진행할 수 있다.

$ controlplane ~ ➜  k taint node controlplane node-role.kubernetes.io/control-plane:NoSchedule-
node/controlplane untainted

 

11. What is the state of the pod mosquito now?

$ controlplane ~ ➜  k get pods
NAME       READY   STATUS    RESTARTS   AGE
bee        1/1     Running   0          4m29s
mosquito   1/1     Running   0          16m
nginx      1/1     Running   0          5m47s


answer : Running

 

12. Which node is the POD mosquito on now?

$controlplane ~ ➜  k get pods mosquito -o wide
NAME       READY   STATUS    RESTARTS   AGE   IP           NODE           NOMINATED NODE   READINESS GATES
mosquito   1/1     Running   0          16m   10.244.0.4   controlplane   <none>           <none>


answer : controlplane


controlplane 노드의 NoSchedule taint 옵션을 제거했기 때문에 Pending 중인 mosquito pod는 controlplane 노드로 스케쥴 되었다.

'IT 기술 > k8s' 카테고리의 다른 글

[cka] Resource Limits  (0) 2024.06.22
[cka] Node Affinity  (0) 2024.06.08
[cka] Labels and Selectors  (0) 2024.06.08
[cka] Manual Scheduling  (0) 2024.06.08
[cka] Imperative Command  (1) 2024.06.01

댓글