Search

Taint & Toleration

Taint

Taint에 대한 사전적인 내용을 보면 "오염"으로 풀이된다. 즉,Node가 오염되었기 때문에 Pod의 Schedule을 제한한다.
보통Taint는 특정 Node에 대해 특정 Pod만 실행할 수 있도록 역할을 제한하기 위한 목적으로 많이 사용된다.- 예를들어) Batch Node에는 System batch pod만 Schedule되어야한다. 모든 Pod 별로 Nodename을 지정하면 문제가 없겠지만, 지정하지 않는 Pod이 발생할 수 있고 이러한 문제를 미연에 방지하고자 Batch Node에 Taint 설정을 하는것이다.
nodename : Taint 설정을 할 nodename이다.
key=value : Taint에 대한 Tolerations에 부합하는 값이다.
option : Taint에 대한 역할 제한이다.
일반적으로 NoSchedule, PreferNoschedule, NoExecute 3가지 설정이 존재한다.

Option

NoSchedule : Pod를 해당 Node에 Schedule 할 수 없다. 단, 기존 실행되던 Pod에는 적용안된다.
PreferNoschdule : Pod를 해당 Node에 Schedule 할 수 없다. 다만, NoSchedule과는 다르게 필수값 X
즉 Cluster 내의 자원이 부족하거나 특정 상황에 따라서는 Taint 설정된 Node에 Pod이 배포될 수 있다.
NoExecute : Pod에 대해 Toleration 설정이 없으면, Schedule 되지 않고 기존에 실행되던 Pod도 Delete 된다.
구분
역할
Pod Schedule
기존 Pod 영향
NoSchedule
Pod no Schedule
Toleration 필수값
영향 없음
PreferNoschdule
Pod no Schedule
Toleration 선택적 값
영향 없음
NoExecute
Pod no Schedule & no Execute
Toleration 필수값
영향 있음
Add Taint
kubectl taint node <Node Name> <key>=<value>:<option>
Shell
복사
Delete Taint
kubectl taint node <Node Name> <key>=<value>:<option>-
Shell
복사

Toleration

위에서 Taint가 "오염"이라고 했다면, Tolerations는 해당 "오염"을 견딜 수 있는 "내성"을 뜻한다. 즉, Taint 설정이 되어있더라도 해당 Taint에 부합하는 value를 Pod Tolerations에 지정하면 해당 Node에 Schedule 될 수 있다.
Pod Toleration 설정
[node01 Taint 명령어] kubectl taint node node01 app=nginx:NoSchedule [node01 pod toleration yaml 파일] apiVersion: v1 kind: Pod metadata: name: taint-test ... spec: tolerations: - effect: NoSchedule key: app value: nginx - ... ...
YAML
복사