Kubernetes/삽질

[k8s/kube-prometheus-stack] node_exporter pending 현상

비번변경 2023. 3. 12. 22:41

현상

쿠버네티스 클러스터 내 리소스를 모니터링하기 위해 kube-prometheus-stack helm chart로 Grafana와 Prometheus를 설치해서 사용하고 있다. 다만 설치한 helm-release의 설정 변경이 필요해, 운영 환경에 적용하기 전에 테스트를 하고자 별도의 네임스페이스에 kube-prometheus-stack chart를 다른 helm-release로 설치했다.

helm-release는 정상적으로 설치되었으나 다음과 같이 node_export pod가 pending 상태로 머물러 있는 것을 확인했다.

 

 

원인

node-exporter를 describe 명령으로 살펴보면 Events 항목에 아래와 같은 메시지를 확인할 수 있다.

node(s) didn't have free ports for the requested pod ports.

node-exporter가 사용하고자 하는 포트가 이미 사용 중이기 때문에 충돌이 발생한 게 원인이다.

이 글의 경우 같은 하나의 클러스터에 같은 소프트웨어를 포트를 변경하지 않고 설치해서 그렇다…….

 

 

해결 방법

node-exporter가 사용할 port를 변경한다. 기본값은 9100이므로 9101 정도로 변경해준다.

이 글에서는 테스트 목적으로 설치한 것이기 때문에 설정 유지가 필요하지 않아 edit으로 작업한다. 만약 변경한 설정을 유지해야 한다면 chart 쪽을 수정하는 것이 좋다.

 

변경할 부분은 다음과 같다.

1. service/prometheus-node-exporter port 수정

kubectl edit service -n <ns> <hr>-prometheus-node-exporter

 

수정 부분

spec:
  clusterIP: 10.108.253.209
  ports:
  - name: metrics
    port: 9101 # 수정
    protocol: TCP
    targetPort: 9101 # 수정

 

2. daemonset/prometheus-node-exporter port 수정

kubectl edit daemonsets.apps -n <ns> <hr>-prometheus-node-exporter

 

수정 부분

    spec:
      containers:
      - args:
        - --path.procfs=/host/proc
        - --path.sysfs=/host/sys
        - --path.rootfs=/host/root
        - --web.listen-address=$(HOST_IP):9101 # 수정
        - --collector.filesystem.ignored-mount-points=^/(dev|proc|sys|var/lib/docker/.+)($|/)
        - --collector.filesystem.ignored-fs-types=^(autofs|binfmt_misc|cgroup|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|mqueue|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|sysfs|tracefs)$
        env:
        - name: HOST_IP
          value: 0.0.0.0
        image: quay.io/prometheus/node-exporter:v1.0.1
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /
            port: 9101 # 수정
            scheme: HTTP
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        name: node-exporter
        ports:
        - containerPort: 9101 # 수정
          hostPort: 9101 # 수정
          name: metrics
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /
            port: 9101 # 수정
            scheme: HTTP

 

 

참고 문서

https://github.com/knative/serving/issues/8646

 

 

728x90