I am trying to configure a persistent disk for Kafka in Kubernetes, I need to set the mount path to /kafka/POD_NAME/.
I can get the pod name as explained here from:
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
I am asking how to use this POD_NAME
inside the mountPath
value, something like: `/
The Downward API, as the name indicates, is used to expose extra kubernetes related information to the containers. What you want is for your yaml file definitions to have variable or dynamic values based on the runtime pods being launched. This is currently not possible.
You might want to try to do something with Helm templates which in a StatefulSet with a PVC would allow you to have predictable pod+volume names and maybe insert a dynamic mountpath, but I haven't tried this myself.
Further, if you're setting this up as recommended, which is in a StatefulSet, it is preferable that the inner spec template for the containers are exactly the same.