# \[ERROR\] - Kubernetes Module - reading bearer token file

**URL:** <https://discuss.elastic.co/t/error-kubernetes-module-reading-bearer-token-file/183408>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [May 29, 2019, 7:14pm UTC](https://discuss.elastic.co/t/error-kubernetes-module-reading-bearer-token-file/183408 "2019-05-29T19:14:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![grfneto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grfneto/32/125776_2.png) [@grfneto](https://discuss.elastic.co/u/grfneto)\
**Post date:** [May 29, 2019, 7:14pm UTC](https://discuss.elastic.co/t/error-kubernetes-module-reading-bearer-token-file/183408/1 "2019-05-29T19:14:37Z")

</div>

Hi everyone.

I have Kubernetes 1.14.1, tried monitoring my cluster with Metricbeat 6.6.1 and Elasticsearch/Kibana. I used the follow configuration in **kubernetes.yml** :

```auto
- module: kubernetes
  metricsets:
    - node
    - system
    - pod
    - container
    - volume
  period: 10s
  hosts: ["https://kubernetes-master:10250"]
  bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  ssl.certificate_authorities:
    - /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt

```

but, i received the **error** below:

```auto
    INFO instance/beat.go:281 Setup Beat: metricbeat; Version: 6.6.1
    INFO add_cloud_metadata/add_cloud_metadata.go:319 add_cloud_metadata: hosting provider type not detected.
    INFO elasticsearch/client.go:165 Elasticsearch url: http://elasticsearch:9200
    INFO [publisher] pipeline/module.go:110 Beat name: kubernetes-master
    INFO [monitoring] log/log.go:117 Starting metrics logging every 30s
    INFO instance/beat.go:403 metricbeat start running.
    INFO [monitoring] log/log.go:152 Total non-zero metrics {"monitoring": {"metrics": {"beat":{"cpu":{"system":{"ticks":90,"time":{"ms":93}},"total":{"ticks":170,"time":{"ms":178},"value":170},"user":{"ticks":80,"time":{"ms":85}}},"handles":{"limit":{"hard":4096,"soft":1024},"open":6},"info":{"ephemeral_id":"b947d375-e201-4b03-b628-2aa87de42297","uptime":{"ms":3097}},"memstats":{"gc_next":5542016,"memory_alloc":2976672,"memory_total":9877728,"rss":25583616}},"libbeat":{"config":{"module":{"running":0}},"output":{"type":"elasticsearch"},"pipeline":{"clients":0,"events":{"active":0}}},"system":{"cpu":{"cores":4},"load":{"1":0.19,"15":0.26,"5":0.2,"norm":{"1":0.0475,"15":0.065,"5":0.05}}}}}}
    INFO [monitoring] log/log.go:153 Uptime: 3.10495974s
    INFO [monitoring] log/log.go:130 Stopping metrics logging.
    INFO instance/beat.go:413 metricbeat stopped.
    ERROR instance/beat.go:911 Exiting: 1 error: 5 errors: reading bearer token file: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory; reading bearer token file: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory; reading bearer token file: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory; reading bearer token file: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory; reading bearer token file: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory

```

i saw many topics about this, already add the property **ssl.verification\_mode: none** but without success. continue the same error, how can i solution it?

---

<div class="post-metadata">

**Author:** ![Kaiyan\_Sheng](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kaiyan_sheng/32/38247_2.png) [@Kaiyan\_Sheng](https://discuss.elastic.co/u/Kaiyan_Sheng)\
**Post date:** [May 30, 2019, 4:48pm UTC](https://discuss.elastic.co/t/error-kubernetes-module-reading-bearer-token-file/183408/2 "2019-05-30T16:48:31Z")

</div>

@grfneto Sorry I don't know kubernetes module besides using it with

```auto
- module: kubernetes
      metricsets:
        - node
        - system
        - pod
        - container
        - volume
      period: 10s
      host: ${NODE_NAME}
      hosts: ["localhost:10255"]

```

@exekias we need your help here 😬

---

<div class="post-metadata">

**Author:** ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)\
**Post date:** [May 31, 2019, 7:28am UTC](https://discuss.elastic.co/t/error-kubernetes-module-reading-bearer-token-file/183408/3 "2019-05-31T07:28:00Z")

</div>

Hi @grfneto,

How are you running Metricbeat? We use this service account token to access the API, have a look to: [https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod](https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod).

If Metricbeat is correctly configured, I would expect that file to exist inside the pod, and contain the token to do authentication.

Best regards

---

<div class="post-metadata">

**Author:** ![grfneto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grfneto/32/125776_2.png) [@grfneto](https://discuss.elastic.co/u/grfneto)\
**Post date:** [May 31, 2019, 1:21pm UTC](https://discuss.elastic.co/t/error-kubernetes-module-reading-bearer-token-file/183408/4 "2019-05-31T13:21:12Z")

</div>

hi @Kaiyan_Sheng I used the [getting started with metricbeat](https://www.elastic.co/guide/en/beats/metricbeat/6.6/metricbeat-getting-started.html) option download rpm and i enabled the module kubernetes in the settings `/etc/metricbeat/modules.d/kubernetes.yml` file.

---

<div class="post-metadata">

**Author:** ![grfneto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grfneto/32/125776_2.png) [@grfneto](https://discuss.elastic.co/u/grfneto)\
**Post date:** [May 31, 2019, 1:27pm UTC](https://discuss.elastic.co/t/error-kubernetes-module-reading-bearer-token-file/183408/5 "2019-05-31T13:27:46Z")

</div>

Hi @exekias the status of service is running but the log file show message of error and nothing arrived in the elasticsearch. 🙁

---

<div class="post-metadata">

**Author:** ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)\
**Post date:** [June 4, 2019, 7:51am UTC](https://discuss.elastic.co/t/error-kubernetes-module-reading-bearer-token-file/183408/6 "2019-06-04T07:51:18Z")

</div>

Hi,

You can probably benefit from this guide: [https://www.elastic.co/guide/en/beats/metricbeat/current/running-on-kubernetes.html](https://www.elastic.co/guide/en/beats/metricbeat/current/running-on-kubernetes.html)

It shows how to run Metricbeat as a daemonset, so it gets run inside Kubernetes and gets access to the required APIs

---

<div class="post-metadata">

**Author:** ![grfneto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grfneto/32/125776_2.png) [@grfneto](https://discuss.elastic.co/u/grfneto)\
**Post date:** [June 5, 2019, 2:52pm UTC](https://discuss.elastic.co/t/error-kubernetes-module-reading-bearer-token-file/183408/7 "2019-06-05T14:52:19Z")

</div>

Thank you @exekias

I did it this way.

best regards 😉

---

<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:** [July 3, 2019, 2:52pm UTC](https://discuss.elastic.co/t/error-kubernetes-module-reading-bearer-token-file/183408/8 "2019-07-03T14:52:26Z")

</div>

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