CKA
Node Selector & Affinities
백셀건전지
2021. 9. 5. 21:06
- 특정 pod를 특정 node에 띄우기 위한 방법은 두 가지
- NodeSelector
- spec.nodeSelector로 pod 의 definition에 정의.
- node에 정의된 label로 key:value 선언
- kubectl label nodes <node-name> <label-key>=<label-value>: node에 label 주는 방법
- node Selectors로는 or 조건이나 not 조건을 추가할 수 없음
- Node Affinity
- 더욱 복잡하고 다양한 조건을 위한 기능
- operator을 In과 NotIn으로 설정할 수 있고, 이의 대상은 values 내의 label value array이다.
- operator이 exists는 affinity에 선언한 key값이 있는 node들을 대상으로 적용됨. value section은 값을 비교하지 않기 때문에 필요 없음.
- 3개의 node affinity type
- requiredDuringSchedulingIgnoredDuringExecution: 조건 맞는 node 없으면 evicted
- preferredDuringSchedulingIgnoredDuringExecution: 일단 조건 맞춰보고 안되면 scheduler 알아서.
- requiredDuringSchedulingRequiredDuringExecution: 조건 맞는 node에 배포했는데 후에 node label이 바뀌면 현재 떠있는 pod terminate 시킴