# K8s env how to set pod-name ends with 0-N numbers

**URL:** <https://discuss.kubernetes.io/t/k8s-env-how-to-set-pod-name-ends-with-0-n-numbers/25646>\
**Category:** General Discussions\
**Tags:** docs, development\
**Created:** [October 7, 2023, 9:56am UTC](https://discuss.kubernetes.io/t/k8s-env-how-to-set-pod-name-ends-with-0-n-numbers/25646 "2023-10-07T09:56:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![haiyang](https://avatars.discourse-cdn.com/v4/letter/h/ce7236/32.png) [@haiyang](https://discuss.kubernetes.io/u/haiyang)\
**Post date:** [October 7, 2023, 9:56am UTC](https://discuss.kubernetes.io/t/k8s-env-how-to-set-pod-name-ends-with-0-n-numbers/25646/1 "2023-10-07T09:56:30Z")

</div>

Asking for help? Comment out what you need so we can get more information to help you!

### Cluster information:

Kubernetes version: 1.18  
Cloud being used: (put bare-metal if not on a public cloud) bare metal  
Installation method: kubeadm  
Host OS: centos7  
docker version: 19.03.9  
hello I want to ask a question , I want to deploy one zookeeper cluster , I want to get pod names ending with 0-N numbers by env “valueFrom” , for example:  
I deployed three pods named zookeeper through statefulset mode. Their three pod names are zookeeper-0, zookeeper-1 and zookeeper-2. How do I get the final 0, 1 and 2?  
I found that I can only get the pod-name. Here is how I got it. Can anyone help me find out how to get the number?

```
      **env:**

```

\*\* - name: ZOO\_SERVER\_ID\*\*  
\*\* valueFrom:\*\*  
\*\* fieldRef:\*\*  
\*\* fieldPath: metadata.labels[‘[statefulset.kubernetes.io/pod-name](http://statefulset.kubernetes.io/pod-name)’]\*\*

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.
