-
Kubernetes 특정 Node로 Pod 배포Kubernetes 2019. 10. 2. 14:54
Kubernetes Cluster 환경에서 어플리케이션이 특정 노드에서만 실행 되게끔 하는 것이 가능하다.
Kubernetes Cluster가 3대의 Node로 이루어져 있다고 가정했을 때, 각 장비들에 Label을 붙인 뒤 원하는 Label로 Pod이 Deployment 되도록 요청하면 된다.
1. 노드에 Label 정보 추가
Node label 설정을 위한 Command 2. 적용
2.1 nodeSelector
nodeSelector가 적용된 pod yaml 파일 2.2 Affinity
nodeSelector보다 고급적인 표현식으로 노드를 선택하고 싶으면 Affinity || inter pod affinity를 이용하면 된다.
실제 Kubernetes에서는 아래와 같은 장점을 말하며 nodeSelector보다 이 방식을 권장하고 있다.
- 표현식이 좀 더 다양하다. ( exact match의 AND 조합을 벗어남 )
- hard한 명시보다 soft/preference 설정에 가깝게 바꿔준다.
- 제약조건을 node 자체보다 POD간에 부여하는 방식으로 서로 같이 배치될 수 있는 POD과 그렇지 않은 POD 정의 가능
affinity는 크게 node affinity와 inter-pod affinity, anti-affinity로 나뉜다.
node affinity ≒ nodeSelector && inter-pod affinity / anti-affinity ≒ pod label
2.2.1 Node Affinity
nodeSelector와 유사하며, 현재 두가지 타입의 node affinity가 있고 두 타입을 조합해서 사용한다.
Type1 : [ required || preferred ] + DuringScheduling = 스케줄링 과정에서 조건을 반드시 충족 or 선호 정도 차이
Type2 : [ Ignored || Required ] + DuringExecution = Runtime에 Node label이 바뀌더라도 무시할 것인지 아닌지
조합 가능한 조건
- requiredDuringSchedulingIgnoredDuringExecution // 반드시 조건에 맞는 노드에 POD를 배포해라
- preferredDuringSchedulingIgnoredDuringExecution // 조건에 맞는 노드에 배포하면 좋지만 아니면 다른데 배포
- requiredDuringSchedulingRequiredDuringExecution //
- preferredDuringSchedulingRequiredDuringExecution
node affinity가 적용된 pod yaml operator 종류
- In
- NotIn
- Exists
- DoesNotExist
- Gt
- Lt
'Kubernetes' 카테고리의 다른 글
Helm Charts (0) 2019.11.01 Kubernetes Persistent Volume (0) 2019.10.08 Kubernetes GPU Container (0) 2019.10.02 Kubernetes PKI Certificate (0) 2019.10.02 Kubernetes CPU Affinity (0) 2019.10.01