categraf deamonset方式部署,采集主机磁盘使用率报错

Viewed 166

categraf deamonset方式部署(腾讯云主机/data目录挂了单独的磁盘),采集磁盘使用率报如下错误:
2023/04/06 19:16:40 ps.go:150: E! failed to get disk usage, mountpoint: /hostfs/data error: no such file or directory

请帮忙看看。

6 Answers

容器里容器外分别执行df -h看看

另外容器外执行cat /proc/mounts贴下结果。容器内执行cat /hostfs/proc/mounts 贴下结果。把截图都补充到问题里

还有volume挂载是怎么配置的,也贴一下

cat /proc/mounts,cat /hostfs/proc/mounts ,这两个结果太长了,不好截图,也不好发文字。

除了秦老师提到的,检查下

引用
- name: HOST_PROC
value: /hostfs/proc
- name: HOST_SYS
value: /hostfs/sys
- name: HOST_MOUNT_PREFIX
value: /hostfs

这部分都还在daemonset中吗

  • name: HOST_PROC
    value: /hostfs/proc
    - name: HOST_SYS
    value: /hostfs/sys
    - name: HOST_MOUNT_PREFIX
    value: /hostfs

daemonset的这些内容在的

还有后续吗?

不好意思,上午太忙,已经补充了一些信息

volume挂载
volumeMounts:
- mountPath: /etc/categraf/conf/config.toml
name:categraf-config
subPath: config.toml
- mountPath: /etc/categraf/conf/input.kubernetes/kubernetes.toml
name:categraf-config-kubernetes
subPath: kubernetes.toml
- mountPath: /etc/categraf/conf/input.prometheus/prometheus.toml
name:categraf-config-prometheus
subPath: prometheus.toml
- mountPath: /var/run/utmp
name: hostroutmp
readOnly: true
- mountPath: /hostfs/proc
name: hostrofs-proc
readOnly: true
- mountPath: /hostfs/sys
name: hostrofs-sys
readOnly: true
- mountPath: /hostfs/var
name: hostrofs-var
readOnly: true
- mountPath: /hostfs/run
name: hostrofs-run
readOnly: true
- mountPath: /hostfs/dev
name: hostrofs-dev
readOnly: true
- mountPath: /var/run/docker.sock
name: docker-socket

step1 这里是定义根目录的volume为hosrofs

https://github.com/flashcatcloud/categraf/blob/main/k8s/daemonset.yaml#L703

step2 将上面定义的hostrofs挂载到容器的/hostfs路径下

https://github.com/flashcatcloud/categraf/blob/main/k8s/daemonset.yaml#L623

step3 告诉categraf 物理机的路径前缀是/hostfs

https://github.com/flashcatcloud/categraf/blob/main/k8s/daemonset.yaml#L579

对着检查下

已找到原因,少了配置。
image.png