alexvaut / cStatsExporter

Windows Docker Stats exporter
Apache License 2.0
15 stars 9 forks source link

cStatsExporter crashes when run as a DaemonSet on Kubernetes #13

Closed OrangeTimes closed 4 years ago

OrangeTimes commented 4 years ago

Kubernetes version: v.1.15.6 Docker Engine on kubernetes node: 19.3.4 Server: Windows Server 2019 Standard 10.0.17763.1217

Steps to reproduce:

  1. Build and create container from latest sources. Enable Kubernetes support
  2. Deploy to Kubernetes cluster with some windows node using deployment file
    apiVersion: apps/v1
    kind: DaemonSet
    metadata:
    name: cstatsexporter-windows
    namespace: monitoring
    labels:
    k8s-app: cstatsexporter-windows
    version: v1
    spec:
    selector:
    matchLabels:
      k8s-app: cstatsexporter-windows
      version: v1
    template:
    metadata:
      labels:
        k8s-app: cstatsexporter-windows
        version: v1
    spec:
      nodeSelector:
        kubernetes.io/os: windows
      containers:
      - name: cstatsexporter-windows
        image: cstatsexporter:latest
        resources:
          limits:
            memory: 500Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - mountPath: \\.\pipe\docker-engine
          name: docker-pipe
      terminationGracePeriodSeconds: 30
      volumes:
      - name: docker-pipe
        hostPath: 
          path: \\.\pipe\docker-engine
          type: null

    Actual result: The same image works smoothly if run using docker on kubernetes node but Kuberentes pods crashes. If you analyze logs you will see error dring startup of cStatsExporter: Starting... Configuration read. Scrap time = 15 seconds. panic: error during connect: This error may indicate that the docker daemon is not running.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json?limit=0": open //./pipe/docker_engine: The system cannot find the file specified.

goroutine 1 [running]: main.GatherMetrics() /main.go:285 +0x221d main.main() /main.go:121 +0x129

DerrickMartinez commented 4 years ago

It's docker_engine not docker-engine.

      - name: docker-pipe
        hostPath:
          path: '\\.\pipe\docker_engine'
          type: null

Also you'll want


        env:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
OrangeTimes commented 4 years ago

Thanks