Telegraf for k8s collection data ERR

[inputs.kubernetes] Error in plugin: https://0.0.0.0:10250/stats/summary returned HTTP status 403 Forbidden

deploy telegraf in k8s,the config is that

[[inputs.kubernetes]]
  url = "https://0.0.0.0:10250"
  bearer_token = "/var/run/secrets/kubernetes.io/serviceaccount/token"
  insecure_skip_verify = true

i have try change 0.0.0.0 to 127.0.0.1 but also ERR

and /var/run/secrets/kubernetes.io/serviceaccount/token is right

k8s version v1.20.6 telegraf 1.20

Hi @Dhongwei,
I believe your issue could be related to this open issue: Kubernetes input plugin not working (deprecated /stats/summary endpoint?) · Issue #6959 · influxdata/telegraf · GitHub
. It appears that most are working around the issue by using the Telegraf DaemonSet: helm-charts/charts/telegraf-ds at master · influxdata/helm-charts · GitHub. I will reraise this with the Telegraf team for further investigation around the kubernetes plugin.

Hi @Dhongwei,
I spoke with the team. They have also asked if you have tried creating a Service Account and ClusterRoleBinding for telegraf using the yaml configuration below. Mind the namespace.

apiVersion: v1
kind: ServiceAccount
metadata:
  name: telegraf
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: metric-scanner-kubelet-api-admin
subjects:
- kind: ServiceAccount
  name: telegraf
  namespace: influxdb
roleRef:
  kind: ClusterRole
  name: system:kubelet-api-admin
  apiGroup: rbac.authorization.k8s.io 

Thank you very much. I just wrote this ymal wrong
My problem has been solved Thank you for your help

1 Like