skip to Main Content
Error: failed to start container "node-exporter": Error response from daemon: path /sys is mounted on /sys but it is not a shared or slave mount

shows that message here is the repository I took it from trying to make a node exporter to Grafana dashboard through Kubernetes pods followed this video and this repo

ERROR screenshot
enter image description here

3

Answers


  1. Well for me (Docker-Desktop in MacOS) this command saved my day:

    kubectl patch ds monitoring-prometheus-node-exporter --type "json" -p '[{"op": "remove", "path" : "/spec/template/spec/containers/0/volumeMounts/2/mountPropagation"}]'
    

    credit: GitHub Issues

    Login or Signup to reply.
  2. This work for me (Docker-Dektop in MacOs m1)

    # Mount the node's root file system (/) at /host/root in the container
    hostRootFsMount:
      enabled: false
      # Defines how new mounts in existing mounts on the node or in the container
      # are propagated to the container or node, respectively. Possible values are
      # None, HostToContainer, and Bidirectional. If this field is omitted, then
      # None is used. More information on:
      # https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation
      mountPropagation: HostToContainer
    

    enter image description here

    Login or Signup to reply.
  3. What is the issue


    This is not an issue of node exporter or helm chart or Kubernetes or docker but a limitation of docker desktop. Only people using Kubernetes on the docker desktop should be the ones facing the issue.

    Take a look at the values.yaml from prometheus-node-exporter

    # Mount the node's root file system (/) at /host/root in the container
    hostRootFsMount:
      enabled: true
      # Defines how new mounts in existing mounts on the node or in the container
      # are propagated to the container or node, respectively. Possible values are
      # None, HostToContainer, and Bidirectional. If this field is omitted, then
      # None is used. More information on:
      # https://kubernetes.io/docs/concepts/storage/volumes/#mount-propagation
      mountPropagation: HostToContainer
    

    It is using mount propagation. Now, take a look at the docker documentation::

    Bind propagation defaults to rprivate for both bind mounts and volumes. It is only configurable for bind mounts, and only on Linux host machines. Bind propagation is an advanced topic and many users never need to configure it.

    furthermore, and the most important one:
    Image containing Warning message stating that Mount propagations don't work with Docker Desktop from docker documentation

    Okay but tell me how to solve it


    You can turn off the hostRootFsMount, of course, by using the kubectl patch as suggested by Ali’s answer, or you can use

    helm install prom prometheus-community/kube-prometheus-stack -f node-exporter-workaround.yaml
    OR
    helm install prom prometheus-community/kube-prometheus-stack --set prometheus-node-exporter.hostRootFsMount.enabled=false
    
    # node-exporter-workaround.yaml
    prometheus-node-exporter:
      hostRootFsMount:
        enabled: false
    

    I am using kube-prometheus-stack chart in my case, and it contains the dependency of node exporter with the name prometheus-node-exporter, thus the first line of the yaml contains prometheus-node-exporter, and it can be different if the name of the dependency is different for the chart you are using.

    dependencies:
      ...
      - name: prometheus-node-exporter
        version: "4.14.*"
        repository: https://prometheus-community.github.io/helm-charts
        condition: nodeExporter.enabled
    

    If you are using the prometheus-node-exporter chart directly, then you can install it with --set hostRootFsMount.enabled=false

    BUT


    Bear in mind that by disabling mount propagation node-exporter won’t be able to collect all data needed for grafana dashboards and for alerts. — paulfantom [maintainer]

    So, what does this mean?
    It means this is a workaround and not a solution. There are side effects to it. But on the bright side, this is a docker desktop issue. Prometheus should work fine on your production clusters. But if you are using docker desktop as your production env, then you need to reconsider some of your life choices. Have a nice day! 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search