I am going to utilize the pod IP environment variable in my K8s deployment so that the pod IP should be assigned to a container's argument which is listening on this IP. I tried to fetch pod IP via "status.podIP" and retrieve it in the arg section as follow:
env:
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
the container is a proxy application which is listening on the pod IP and its own port number.
- args:
- --listen=MY_POD_IP:XXXX
But this setup sometimes returns a binding error as:
bind: cannot assign requested address
and sometimes the server error as:
listen tcp: lookup MY_POD_IP: server misbehaving
If I replace the MY_POD_IP with the actual pod IP, the setup works fine, but since this pod IP is generated dynamically in every deployment, I need to have a general solution to assign this IP to my argument. Any idea or workaround?
Thank you in advance.