dabealu / zookeeper-exporter

zookeeper exporter for prometheus
MIT License
139 stars 74 forks source link

Exporter unknown port in kubernetes #27

Closed dotbalo closed 4 years ago

dotbalo commented 4 years ago

Thank you very much for your open source project.

I run a zookeeper cluster in Kubernetes, and then use exporter to collect data, but exporter reports an error: unknown port. My exporter is also deployed in Kubernetes.

logs:

[root@k8s-master01 kafka]# kubectl logs -f zookeeper-exporter-7ddf65cc6-lbd6x -n public-service
2020/04/29 14:15:36 info: zookeeper addresses ["zookeeper-0.zookeeper-headless.public-service.svc.cluster.local:2181" --timeout=5]
2020/04/29 14:15:36 info: serving metrics at 0.0.0.0:8080/metrics
2020/04/29 14:17:13 warning: cannot resolve zk hostname '"zookeeper-0.zookeeper-headless.public-service.svc.cluster.local:2181" --timeout=5': address tcp/2181" --timeout=5: unknown port

Pods:

[root@k8s-master01 kafka]# kubectl get po -n public-service
NAME                                 READY   STATUS    RESTARTS   AGE
elasticsearch-logging-0              1/1     Running   0          8d
kafka-0                              1/1     Running   0          13m
zookeeper-0                          1/1     Running   0          132m
zookeeper-exporter-7ddf65cc6-lbd6x   1/1     Running   0          2m56s

nslookup:

[root@k8s-master01 kafka]# kubectl exec -ti zookeeper-exporter-7ddf65cc6-lbd6x -n public-service -- nslookup zookeeper-0.zookeeper-headless.public-service.svc.cluster.local
Server:     50.96.0.10
Address:    50.96.0.10:53

Name:   zookeeper-0.zookeeper-headless.public-service.svc.cluster.local
Address: 177.246.65.55

deploy.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: zookeeper-exporter
  name: zookeeper-exporter
  namespace: public-service
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: zookeeper-exporter
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: zookeeper-exporter
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - k8s-master03.xiqu
      containers:
      - args:
        - --zk-list="zookeeper-0.zookeeper-headless.public-service.svc.cluster.local:2181"
          --timeout=5
        env:
        - name: TZ
          value: Asia/Shanghai
        - name: LANG
          value: C.UTF-8
        image: dabealu/zookeeper-exporter:latest
        imagePullPolicy: IfNotPresent
        lifecycle: {}
        name: zookeeper-exporter
        ports:
        - containerPort: 8080
          name: web
          protocol: TCP
        resources:
          limits:
            cpu: 837m
            memory: 448Mi
          requests:
            cpu: 10m
            memory: 10Mi
        securityContext:
          allowPrivilegeEscalation: false
          privileged: false
          procMount: Default
          readOnlyRootFilesystem: false
          runAsNonRoot: false
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /usr/share/zoneinfo/Asia/Shanghai
          name: tz-config
        - mountPath: /etc/localtime
          name: tz-config
        - mountPath: /etc/timezone
          name: timezone
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - hostPath:
          path: /usr/share/zoneinfo/Asia/Shanghai
          type: ""
        name: tz-config
      - hostPath:
          path: /etc/timezone
          type: ""
        name: timezone
dabealu commented 4 years ago

Hi @dotbalo, I think there's missing - in your deployment's args:

      - args:
        - --zk-list="zookeeper-0.zookeeper-headless.public-service.svc.cluster.local:2181"
          --timeout=5

Please try:

      - args:
        - --zk-list="zookeeper-0.zookeeper-headless.public-service.svc.cluster.local:2181"
        - --timeout=5

I guess above should fix the issue, closing this.

dotbalo commented 4 years ago

@dabealu Thank you so much.