# Filebeat Kubernetes autodiscover provider is getting failed with "/var/run/secrets/kubernetes.io/serviceaccount/namespace: no such file or directory" Error

**URL:** <https://discuss.elastic.co/t/filebeat-kubernetes-autodiscover-provider-is-getting-failed-with-var-run-secrets-kubernetes-io-serviceaccount-namespace-no-such-file-or-directory-error/183953>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [June 3, 2019, 12:03pm UTC](https://discuss.elastic.co/t/filebeat-kubernetes-autodiscover-provider-is-getting-failed-with-var-run-secrets-kubernetes-io-serviceaccount-namespace-no-such-file-or-directory-error/183953 "2019-06-03T12:03:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Debashis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/debashis/32/45290_2.png) [@Debashis](https://discuss.elastic.co/u/Debashis)\
**Post date:** [June 3, 2019, 12:03pm UTC](https://discuss.elastic.co/t/filebeat-kubernetes-autodiscover-provider-is-getting-failed-with-var-run-secrets-kubernetes-io-serviceaccount-namespace-no-such-file-or-directory-error/183953/1 "2019-06-03T12:03:35Z")

</div>

Hi - I am using following configuration to autodiscover filebeat pods

```
filebeat.autodiscover:
providers:
- type: kubernetes
templates:
- condition:
equals:
kubernetes.namespace: default
config:
- type: docker
containers.ids:
- "${data.kubernetes.container.id}"

```

I am getting below issue. Please help me to resolve.  
**"Exiting: Unable to get in cluster configuration: open /var/run/secrets/kubernetes.io/serviceaccount/namespace: no such file or directory"**

Thanks

---

<div class="post-metadata">

**Author:** ![MarianaD](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marianad/32/42687_2.png) [@MarianaD](https://discuss.elastic.co/u/MarianaD)\
**Post date:** [June 3, 2019, 12:14pm UTC](https://discuss.elastic.co/t/filebeat-kubernetes-autodiscover-provider-is-getting-failed-with-var-run-secrets-kubernetes-io-serviceaccount-namespace-no-such-file-or-directory-error/183953/2 "2019-06-03T12:14:54Z")

</div>

hi @Debashis, the kubernetes autodiscover provider expects to be running inside the cluster, is this the current situation?

---

<div class="post-metadata">

**Author:** ![Debashis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/debashis/32/45290_2.png) [@Debashis](https://discuss.elastic.co/u/Debashis)\
**Post date:** [June 3, 2019, 12:44pm UTC](https://discuss.elastic.co/t/filebeat-kubernetes-autodiscover-provider-is-getting-failed-with-var-run-secrets-kubernetes-io-serviceaccount-namespace-no-such-file-or-directory-error/183953/3 "2019-06-03T12:44:51Z")

</div>

No @MarianaD. Filebeat is running on host machine where kubernetes is installed. It is not running inside a pod.

---

<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, 11:53am UTC](https://discuss.elastic.co/t/filebeat-kubernetes-autodiscover-provider-is-getting-failed-with-var-run-secrets-kubernetes-io-serviceaccount-namespace-no-such-file-or-directory-error/183953/4 "2019-06-04T11:53:31Z")

</div>

Hi @Debashis,

Filebeat `kubernetes` autodiscover provider will try to autoconfigure itself when run inside Kubernetes. As you are running it from the host, you need to pass certain parameters to make it work. Docs are here: [https://www.elastic.co/guide/en/beats/filebeat/current/configuration-autodiscover.html#\_kubernetes](https://www.elastic.co/guide/en/beats/filebeat/current/configuration-autodiscover.html#_kubernetes)

You will basically need to provide `kube_config`, pointing to the kubernetes client config file to connect to the cluster. `host` may also be needed, to be set to the name of the node in the cluster, probably `host: ${HOSTNAME}` will do.

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 2, 2019, 11:53am UTC](https://discuss.elastic.co/t/filebeat-kubernetes-autodiscover-provider-is-getting-failed-with-var-run-secrets-kubernetes-io-serviceaccount-namespace-no-such-file-or-directory-error/183953/5 "2019-07-02T11:53:35Z")

</div>

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