Scheduling - 2

han·2022년 3월 8일
0

podAffinity && podAntiAffinity

  • 노드에서 이미 실행 중인 파드 레이블을 기반으로 파드가 스케줄
  • matchExpressions에 node가 아닌 이미 배포되어 있는 pod label의 key, value에 대해 기술한다.
    • operator: In, NotIn, Exists, DoesNotExist
    • 그 외 세세한 옵션은 Scheduling - 1의 nodeAffinity와 동일하므로 생략한다.
  • topologyKey: node의 key
apiVersion: v1
kind: Pod
metadata:
  name: with-pod-affinity
spec:
  affinity:
    podAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
      - labelSelector:
          matchExpressions:
          - key: security
            operator: In
            values:
            - S1
        topologyKey: topology.kubernetes.io/zone
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 100
        podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: security
              operator: In
              values:
              - S2
          topologyKey: topology.kubernetes.io/zone
  containers:
  - name: with-pod-affinity
    image: k8s.gcr.io/pause:2.0

Taint && Toleration

  • Taint는 node의 옵션이고 아무 파드나 해당 노드에 스케쥴링 되는것을 막는다.
  • Toleration은 pod의 옵션이고 taint 설정이 되어있는 node에 스케줄링 될 수 있다.
    • pod가 해당 taint가 설정된 노드로 스케쥴링이 되는 것이 아니라 될 수 있는 것이다.
  • 예시) kubectl taint nodes node1 key1=value1:NoSchedule
    • key: key1, value: value1, effect: NoSchedule 라는 taint가 생성된다
    • key, value, operator, effect가 모두 매칭되어야 스케쥴링이 가능하다.
    •  tolerations:
       - key: "key1"
         operator: "Equal"
         value: "value1"
         effect: "NoSchedule"
  • effect
    • NoSchedule: taint에 맞는 toleration pod만 스케쥴 될 수 있다.
    • PreferNoSchedule: 정 스케줄링 될 노드가 없으면 해당 노드에도 스케줄링될 수 있다.
    • NoExcute: 이미 존재중인 파드라도 축출된다.
      • 다른 옵션들(nodeAffinity 포함)은 스케쥴링만 막을 뿐 이미 존재하는 파드를 제거하지는 않는다.
      • 아래와 같이 Pod의 podSpec아래 tolerations에 effect: NoExecute를 달아줄 경우 축출되지 않으며 tolerationSeconds를 달아줄 경우 특정 시간(아래의 경우 3600초) 이후 축출된다.
        • tolerations:
          - key: "key1"
            operator: "Equal"
            value: "value1"
            effect: "NoExecute"
            tolerationSeconds: 3600

Referernce

https://kubernetes.io/ko/docs/concepts/scheduling-eviction/taint-and-toleration/
https://kubernetes.io/ko/docs/concepts/scheduling-eviction/assign-pod-node/

0개의 댓글

관련 채용 정보