# Kubernetes Module - Kubelet -unauthorized error

**URL:** <https://discuss.elastic.co/t/kubernetes-module-kubelet-unauthorized-error/170436>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [March 1, 2019, 5:15am UTC](https://discuss.elastic.co/t/kubernetes-module-kubelet-unauthorized-error/170436 "2019-03-01T05:15:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbedadham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pbedadham/32/41426_2.png) [@pbedadham](https://discuss.elastic.co/u/pbedadham)\
**Post date:** [March 1, 2019, 5:15am UTC](https://discuss.elastic.co/t/kubernetes-module-kubelet-unauthorized-error/170436/1 "2019-03-01T05:15:16Z")

</div>

Hi  
I have Kubernetes 1.13.1 and Metricbeat 6.6.1 with Elasticsearch and Kibana. Not getting metrics of Kubelet though Kube-state-metric is working as expected.

## --Not working-- kubernetes.yml: |- - module: kubernetes enabled: true metricsets: - node - system - pod - container - volume period: 10s host: {NODE\_NAME} #hosts: ["https://{HOSTNAME}:10250"] hosts: ["[https://localhost:10250](https://localhost:10250)"] ssl.verification\_mode: none

I see below error in kibana

error.message:HTTP error 401 in container: 401 Unauthorized @timestamp:February 28th 2019, 21:05:53.407 beat.version:6.6.1 beat.name: beat.hostname: host.name: event.dataset:kubernetes.container event.duration:8,696,784 metricset.rtt:8,696 metricset.name:container metricset.module:kubernetes metricset.host:localhost:10250 \_id:vMelN2kB8UQ-YSZ0AFq- \_type:doc \_index:metricbeat-6.6.1-2019.03.01 \_score:  
--------removed hostname in the above message----

Any help is appreciated - Thanks in advance

---

<div class="post-metadata">

**Author:** ![jsoriano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsoriano/32/27920_2.png) [@jsoriano](https://discuss.elastic.co/u/jsoriano)\
**Post date:** [March 1, 2019, 10:26am UTC](https://discuss.elastic.co/t/kubernetes-module-kubelet-unauthorized-error/170436/2 "2019-03-01T10:26:39Z")

</div>

Hi @pbedadham and welcome 🙂

An unauthorized error can mean that actually metricbeat is not being able to authenticate with kubelet. The proper configuration will depend on the configuration of your cluster.

If your kubelet has the plain http port open (defaults to 10255), just use:

```auto
    hosts: ["http://localhost:10255"]

```

If you want to use the secured port, you probably also need to provide some credentials. If you are using service accounts something like this should work:

```auto
    hosts: ["https://localhost:10250"]
    bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
    ssl.certificate_authorities:
      - /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt

```

---

<div class="post-metadata">

**Author:** ![pbedadham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pbedadham/32/41426_2.png) [@pbedadham](https://discuss.elastic.co/u/pbedadham)\
**Post date:** [March 1, 2019, 9:49pm UTC](https://discuss.elastic.co/t/kubernetes-module-kubelet-unauthorized-error/170436/3 "2019-03-01T21:49:22Z")

</div>

## Thanks @jsoriano for reply. Made some changes as per below and it is working.

```
  hosts: ["https://${HOSTNAME}:10250"]
  bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  ssl:
    # disable verification since kubelete uses self signed certificate
    verification_mode: none
    certificate_authorities:
      - /var/run/secrets/kubernetes.io/serviceaccount/ca.crt

```

* * *

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 29, 2019, 9:49pm UTC](https://discuss.elastic.co/t/kubernetes-module-kubelet-unauthorized-error/170436/4 "2019-03-29T21:49:27Z")

</div>

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