# How to feed kubernetes hostname as env variable

**URL:** <https://forums.suse.com/t/how-to-feed-kubernetes-hostname-as-env-variable/12710>\
**Category:** SUSE Rancher Prime\
**Created:** [December 13, 2018, 4:31pm UTC](https://forums.suse.com/t/how-to-feed-kubernetes-hostname-as-env-variable/12710 "2018-12-13T16:31:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhugga](https://avatars.discourse-cdn.com/v4/letter/r/71e660/32.png) [@rhugga](https://forums.suse.com/u/rhugga)\
**Post date:** [December 13, 2018, 4:31pm UTC](https://forums.suse.com/t/how-to-feed-kubernetes-hostname-as-env-variable/12710/1 "2018-12-13T16:31:24Z")

</div>

I’m creating a workload that is intended to run as a cronjob and run on every etcd node.

How can I feed to kubernetes nodename to the container as an environment variable? Is there any kind of variable substitution you can do in a pod spec?

Thx

---

<div class="post-metadata">

**Author:** ![Sarma\_K](https://avatars.discourse-cdn.com/v4/letter/s/f6c823/32.png) [@Sarma\_K](https://forums.suse.com/u/Sarma_K)\
**Post date:** [December 17, 2018, 12:29pm UTC](https://forums.suse.com/t/how-to-feed-kubernetes-hostname-as-env-variable/12710/2 "2018-12-17T12:29:53Z")

</div>

check this out [https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/](https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/)
