We deploy our dockerized java applications to our various environments via kubernetes. We have a need to provide the podID to each docker container inside the pod.
Update: so I should have been more clear. I know already from this handy link from an old posting Downward API , that I can retrieve the podID value during configuration of deploying container this way:
env:
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
My question is how can I either pass this id to the docker container, OR, just as good, is there a way the container can retrieve this information from it's kubernetes context/environment?
Thanks for any insights
You can set the podIP through environment.
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
For Details clieck here
As you mentioned, you do this by using the Downward API, let me try and explain:
When defining this stanza in your pod yaml:
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
You get the pod IP via an environment variable name MY_POD_IP
inside your container