Metricbeat kubernetes module collection 401

I can collect node data, but k8s can't

the configuration

- module: kubernetes
  metricsets:
    - node
    - system
    - pod
    - container
    - volume
  period: 10s
  host: ${NODE_NAME}
  hosts: ["https://${NODE_IP}:10250"]
  bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  ssl:
    verification_mode: none
    certificate_authorities:
      - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt

the log

2020-08-31T04:20:30.255Z	INFO	module/wrapper.go:259	Error fetching data for metricset kubernetes.system: error doing HTTP request to fetch 'system' Metricset data: HTTP error 401 in : 401 Unauthorized
2020-08-31T04:20:30.255Z	INFO	module/wrapper.go:259	Error fetching data for metricset kubernetes.volume: error doing HTTP request to fetch 'volume' Metricset data: HTTP error 401 in : 401 Unauthorized
2020-08-31T04:20:30.348Z	INFO	module/wrapper.go:259	Error fetching data for metricset kubernetes.container: error doing HTTP request to fetch 'container' Metricset data: HTTP error 401 in : 401 Unauthorized
2020-08-31T04:20:30.348Z	INFO	module/wrapper.go:259	Error fetching data for metricset kubernetes.node: error doing HTTP request to fetch 'node' Metricset data: HTTP error 401 in : 401 Unauthorized
2020-08-31T04:20:30.349Z	INFO	module/wrapper.go:259	Error fetching data for metricset kubernetes.pod: error doing HTTP request to fetch 'pod' Metricset data: HTTP error 401 in : 401 Unauthorized

Hi!

Do you actually want to use ssl? If so you need to make sure that you are using the right certificates.
If not you can just comment out these lines:

- module: kubernetes
  metricsets:
    - node
    - system
    - pod
    - container
    - volume
  period: 10s
  host: ${NODE_NAME}
  hosts: ["https://${NODE_IP}:10250"]
  bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  ssl:
    verification_mode: none
    #certificate_authorities:
    #  - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt

See https://github.com/elastic/beats/blob/f2956098ef62b0fec1ae02e7cb9659dd6b9e6fe9/deploy/kubernetes/metricbeat-kubernetes.yaml#L116

sorry for reply later
I tried your suggestion, but it didn't work

- module: kubernetes
  metricsets:
    - node
    - system
    - pod
    - container
    - volume
  period: 10s
  namespace: 'sxc'
  host: ${NODE_NAME}
  hosts: ["https://localhost:10250"]
  bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  ssl.verification_mode: "none"

Do I need to modify the ClusterRole

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.