K8s Taint vs NodeSelector 트러블슈팅
문제 상황#
dev-webs의 Pod들이 Degraded 상태로 ArgoCD 알림 발생:
- dev-order-core
- dev-seat
- dev-queue
원인 분석#
앱 전용 노드(mini-might)가 리소스 부족
원인: Control-plane(mini-gmk)에 node-role.kubernetes.io/control-plane:NoSchedule taint가 있어서, 인프라 Pod들(istio, loki, calico, coredns, metrics-server 등)이 control-plane에서 생성되지 못하고 앱 전용 worker 노드로 밀려옴
mini-might (worker) 에 배치된 인프라 Pod들:
- istio-ingressgateway (2개)
- istiod
- kiali
- loki-0, loki-chunks-cache-0, loki-results-cache-0
- calico-apiserver (2개), calico-kube-controllers, calico-typha
- coredns (2개)
- metrics-server
- alloy
→ 앱 Pod 배포 시 리소스 경합 발생, 새 Pod Pending
상세 분석#
1. Pending Pod 발생#
kubectl get pods -n dev-webs
새 버전 Pod들이 Pending 상태, 이전 버전은 Running 유지
2. 스케줄링 실패 원인#
Warning FailedScheduling default-scheduler
0/2 nodes are available:
1 node(s) didn't match Pod's node affinity/selector,
1 node(s) had untolerated taint {node-role.kubernetes.io/control-plane: }
mini-gmk(control-plane): taint 있어서 스케줄링 불가mini-might(worker):role=app레이블 없어서 nodeSelector 불일치
3. 리소스 과다 할당#
Allocated resources:
memory: 16076Mi (57%) requests, 28295Mi (101%) limits
- replicas가 2로 설정되어 리소스 부족
- RollingUpdate 중 이전/새 버전 Pod 공존으로 더 악화
해결#
1. replicas 축소 (dev 환경)#
# values-auth-guard.yaml, values-queue.yaml, values-seat.yaml
replicaCount: 2 → 1
2. 노드 레이블 추가#
kubectl label node mini-might role=app
3. Taint 제거 (권장)#
kubectl taint nodes mini-gmk node-role.kubernetes.io/control-plane:NoSchedule-
4. NodeSelector로 노드 분리#
| 구분 | nodeSelector |
|---|---|
| 앱 (dev-webs, dev-ai) | kubernetes.io/hostname: mini-might |
| 인프라 (istio, monitoring, loki) | kubernetes.io/hostname: mini-gmk |
Taint vs NodeSelector 비교#
| 방식 | 장점 | 단점 |
|---|---|---|
| Taint/Toleration | 강제성, 실수 방지 | 복잡, 모든 Pod에 toleration 필요 |
| NodeSelector | 단순, 명확 | nodeSelector 누락 시 어디든 배치 가능 |
결론#
- Taint 제거: 관리 복잡성 감소
- NodeSelector만 사용: 단순하고 직관적
- 앱은 worker 노드, 인프라는 control-plane 노드로 명시적 분리
수정된 파일 (303-goormgb-k8s-helm)#
dev/values/apps/#
values-auth-guard.yaml: replicaCount 2→1values-queue.yaml: replicaCount 2→1values-seat.yaml: replicaCount 2→1
dev/values/monitoring/#
values-loki.yaml: nodeSelector 추가
참고 명령어#
# taint 확인
kubectl describe node mini-gmk | grep Taint
# nodeSelector 불일치 확인
kubectl describe pod <pending-pod> | grep -A 5 Events
# 노드 레이블 확인
kubectl get nodes --show-labels
# 인프라 Pod 재배치
kubectl delete pod -n istio-system -l app=istiod