[트러블슈팅] Pod의 "volume node affinity conflict" 에러 해결

brillog·2024년 2월 18일
0

Kubernetes

목록 보기
11/11

에러 메시지

Pod의 status가 'Pending' 상태로 지속되며 정상적으로 뜨지 않아 kubectl describe로 확인해 봤더니 아래와 같이 "volume node affinity conflict" 에러가 발생하였습니다.

Pod 상태 확인

$ kubectl get po -n gitlab
NAME                   READY     STATUS      RESTARTS      AGE
...
gitlab-postgresql-0    0/2       Pending     0             35h

에러 메시지 확인

$ kubectl describe po gitlab-postgresql-0 -n gitlab
...
  Warning  FailedScheduling  71s (x2 over 6m11s)  default-scheduler  0/4 nodes are available: 2 Too many pods, 2 node(s) had volume node affinity conflict. preemption: 0/4 nodes are available: 2 No preemption victims found for incoming pod, 2 Preemption is not helpful for scheduling..

문제 파악

먼저 PV를 확인합니다.

$ kubectl get pv
...
pvc-f3873619-766b-45c4-8aa0-c9abcd5xxxxx   8Gi        RWO            Delete           Bound         gitlab/data-gitlab-postgresql-0                       ebs-sc                  28d
$ kubectl get pv pvc-f3873619-766b-45c4-8aa0-c9abcd5xxxxx -n gitlab -o yaml
...
spec:
  ...
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: topology.ebs.csi.aws.com/zone
          operator: In
          values:
          - ap-northeast-2a #A존

현재 제 EKS 클러스터는 Multi AZ(Zone A,C)로 구성되어 있으며 에러가 발생한 Pod의 PV가 A존에 생성되어 있는 것을 알 수 있습니다.

A존에 't3.2xlarge' Node 2개, C존에 't3.2xlarge' Node 2개가 떠 있는 상태이며 해당 타입의 최대 Pod 개수를 확인해 보겠습니다.

$ kubectl get nodes -o jsonpath="{range .items[*]}{.metadata.labels['beta\.kubernetes\.io\/instance-type']}{'\t'}{.status.capacity.pods}{'\n'}{end}"
t3.2xlarge      17
t3.2xlarge      17
t3.2xlarge      17
t3.2xlarge      17

't3.2xlarge' 타입의 각 Node는 총 17개의 Pod를 가질 수 있으며, 2 Too many pods, 2 node(s) had volume node affinity 에러로 미루어 봤을 때 2개의 A존 Node는 이미 17개의 Pod가 생성되어 있다는 것을 짐작할 수 있습니다.

실제로 아래 명령어로 A존 노드의 Pod 개수를 확인해 봤을 때, 총 17개가 있는 것을 확인하였습니다.

$ kubectl get po --all-namespaces --field-selector "spec.nodeName=ip-10-xxx-xxx-xxx.ap-northeast-2.compute.internal"

문제 해결

A존 Node가 부족한 것이기 때문에 A존에 노드를 하나 더 띄우는 것으로 문제를 해결할 수 있었습니다.

A존 Node 추가
A존 Node 추가

Pod 상태 확인

$ kubectl get po -n gitlab
NAME                   READY     STATUS      RESTARTS      AGE
...
gitlab-postgresql-0    2/2       Running     0             36h
$ kubectl describe pod/gitlab-postgresql-0 -n gitlab
...
  Normal   Scheduled               114s                  default-scheduler        Successfully assigned gitlab/gitlab-postgresql-0 to ip-10-xxx-xxx-xxx.ap-northeast-2.compute.internal
  Normal   SuccessfulAttachVolume  111s                  attachdetach-controller  AttachVolume.Attach succeeded for volume "pvc-f3873619-766b-45c4-8aa0-c9abcd5xxxxx"
  Normal   Pulling                 106s                  kubelet                  Pulling image "docker.io/bitnami/postgresql:13.12.0"
  Normal   Pulled                  96s                   kubelet                  Successfully pulled image "docker.io/bitnami/postgresql:13.12.0" in 9.905388233s (9.905426862s including waiting)
  Normal   Created                 96s                   kubelet                  Created container postgresql
  Normal   Started                 96s                   kubelet                  Started container postgresql
  Normal   Pulling                 96s                   kubelet                  Pulling image "docker.io/bitnami/postgres-exporter:0.12.0-debian-11-r86"
  Normal   Pulled                  88s                   kubelet                  Successfully pulled image "docker.io/bitnami/postgres-exporter:0.12.0-debian-11-r86" in 8.356160206s (8.356173529s including waiting)
  Normal   Created                 88s                   kubelet                  Created container metrics
  Normal   Started                 88s                   kubelet                  Started container metrics

Reference

개인적으로 공부하며 작성한 글로, 내용에 오류가 있을 수 있습니다.

profile
Cloud & DevOps ♡

0개의 댓글