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

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?


** - name: ZOO_SERVER_ID**
** valueFrom:**
** fieldRef:**
** fieldPath: metadata.labels[‘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.