Scheduling-Taints and Tolerations
2024. 12. 31. 03:54ㆍ쿠버네티스/쿠버네티스
728x90
반응형
1. Taints와 Tolerations의 개념
- Taints: 노드에 설정되며, 특정 파드가 해당 노드에 배치되지 않도록 제한합니다.
- Tolerations: 파드에 설정되며, 특정 taint를 가진 노드에서 실행될 수 있도록 허용합니다.
- 이 두 개념은 클러스터 보안이나 침입 방지와는 관련이 없으며, 단순히 파드 배치를 제어하는 데 사용됩니다.
2. 비유를 통한 이해
-
- 노드는 "사람", 파드는 "벌레"로 비유됩니다.
- 사람(노드)에 "스프레이(Taint)"를 뿌리면, 벌레(파드)가 접근하지 못합니다.
- 하지만 특정 벌레는 이 스프레이 냄새를 견딜 수 있습니다(Toleration). 이러한 벌레는 사람에게 접근할 수 있습니다.
3. 사용 예시
-
-
- 기본적으로 Kubernetes 스케줄러는 파드를 모든 노드에 균등하게 분배합니다.
- 특정 노드(예: Node 1)를 특정 애플리케이션 전용으로 사용하려면 다음 절차를 따릅니다:
- Node 1에 taint를 추가하여 기본적으로 모든 파드를 거부합니다.
- 특정 파드(예: Pod D)에 toleration을 추가하여 Node 1에서 실행될 수 있도록 허용합니다.
-
4. Taints와 Tolerations의 적용
- Taint 추가 명령어: kubectl taint nodes <노드 이름> <key>=<value>:<effect>
- 예: kubectl taint nodes node1 app=blue:NoSchedule
- effect 값:
- NoSchedule: 해당 taint를 견디지 못하는 파드는 배치되지 않습니다.
- PreferNoSchedule: 해당 taint 를 견디지 못하는 파드는 가능하면 배치되지 않지만, 강제는 아닙니다.
- NoExecute: 기존에 배치된 파드는 퇴출되며, 새로운 파드는 배치되지 않습니다.
- 파드 정의 파일의 spec 섹션에 toleration을 추가합니다.

- NoExecute taint가 적용된 경우:
- 기존 노드에서 실행 중인 파드 중 toleration이 없는 경우 퇴출(eviction)됩니다., C 파드는 퇴출
- toleration이 있는 파드는 계속 실행됩니다.
제한 사항
- Taints와 Tolerations은 특정 노드에서 어떤 파드를 허용할지를 결정하지만, 특정 노드로 반드시 배치되도록 보장하지는 않습니다. 예를들어 위에 그림처럼 D가 반드시 Node1에 가라는법은 없음, Node2, 3에도 배치 될 수 있음.
- 특정 노드로만 파드를 배치하려면 Node Affinity라는 별도의 개념을 사용해야 합니다.
Master 기본적으로 배치되지 않는다.

- NoSchedule로 설정되어 있음.
Create a taint on node01 with key of spray, value of mortein and effect of NoSchedule
- kubectl taint nodes node01 spray=mortein:NoSchedule
Create another pod named bee with the nginx image, which has a toleration set to the taint mortein.

Remove the taint on controlplane, which currently has the taint effect of NoSchedule.
- kubectl taint nodes controlplane node-role.kubernetes.io/control-plane:NoSchedule-
반응형
'쿠버네티스 > 쿠버네티스' 카테고리의 다른 글
Scheduling-Resource Requirements and Limits (0) | 2024.12.31 |
---|---|
Scheduling-Node Selectors-Node Affinity (0) | 2024.12.31 |
Scheduling-Labels and Selectors (0) | 2024.12.31 |
Scheduling-Manual Scheduling (0) | 2024.12.31 |
Imperative vs Declarative (0) | 2024.12.31 |