Always-Try(정보보안 및 일상)

[CKA 준비] 섹션 3: Scheduling - Taints and Tolerations, Node Affinity 관련 본문

Kubernetes (Kubernetes security)

[CKA 준비] 섹션 3: Scheduling - Taints and Tolerations, Node Affinity 관련

Always-Try 2026. 5. 3. 21:53

Q1. [Toleration] 특정 노드에 설정된 Taint 때문에 포드가 안 떠요. 어떻게 하죠?

A: 노드에 설정된 Taint(얼룩)를 견딜 수 있도록 포드 설정에 Toleration(내성)을 추가해야 합니다.

  • 해결법: 포드 YAML의 spec 섹션에 tolerations 필드를 작성합니다.
  • 핵심 문법:
  • YAML
    tolerations:
    - key: "spray"
      operator: "Equal"
      value: "mortein"
      effect: "NoSchedule"
    

Q2. [Taint 제거] 노드에 걸린 제약(Taint)을 아예 없애고 싶을 땐?

A: kubectl taint 명령어 끝에 마이너스(-) 기호를 붙여 실행하면 즉시 제거됩니다.

  • 실행 예시:
  • Bash
    # 먼저 describe로 정확한 키와 이펙트 확인
    kubectl describe node controlplane | grep Taints
    # 제거 실행
    kubectl taint nodes controlplane node-role.kubernetes.io/control-plane:NoSchedule-
    

Q3. [Label] Node Affinity를 쓰기 위해 노드에 이름표를 붙이려면?

A: kubectl label 명령어를 사용해 노드에 키-값 쌍의 Label을 부여해야 합니다.

  • 실행 예시:
  • Bash
    # node01에 color=blue 레이블 추가
    kubectl label node node01 color=blue
    # 확인
    kubectl get nodes --show-labels
    

Q4. [Node Affinity] 특정 레이블이 있는 노드에만 포드를 띄우는 법은?

A: 포드나 Deployment의 spec에 Node Affinity 설정을 추가합니다. 가장 강력한 강제성은 requiredDuringScheduling...을 사용합니다.

  • 핵심 문법:
  • YAML
    affinity:
      nodeAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          nodeSelectorTerms:
          - matchExpressions:
            - key: color
              operator: In
              values:
              - blue
    

Q5. [Efficiency] YAML 파일을 처음부터 다 타이핑해야 하나요?

A: 아니요! dry-run 기능을 사용하여 기본 뼈대를 만들고 필요한 부분만 수정하는 것이 가장 효율적입니다.

  • 꿀팁 명령어:
  • Bash
    # Deployment 뼈대 만들기
    kubectl create deployment red --image=nginx --replicas=2 --dry-run=client -o yaml > red.yaml
    
  • 그 다음 vi red.yaml로 들어가서 Affinity나 Toleration 부분만 공식 문서를 참고해 붙여넣으세요.
Comments