<p>I have a worker node where I added an additional interface named eth1 using multus CNI. eth0 is provided by kubernetes. So I have two interfaces. Each interface has an external IP and internal IP. Inside my pod, same eth0 and eth1 internal IPs can be seen. Can I fetch any of external IP or internal IP inside containers using helm inbuilt functions ? Is there a possibility to fetch the IPs using
curl or helm or kubernetes provided objects? I am expecting this IPs to be fetched and used as container's env variables.</p>
<p>It would be really helpful if someone helps me on this. Thanks in advance!</p>

anonymous user
<p>You definitely can't get this information from Helm.  Helm doesn't know where your pods will eventually be scheduled, or what interfaces they'll have, or even if those nodes will still exist before Helm runs again.</p>
<p>The only real way a pod has to find about about its node is the <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="nofollow noreferrer">downward API</a>.  In principle you can use this to find out <em>a</em> node IP address</p>
<pre class="lang-yaml prettyprint-override"><code># templates/deployment.yaml
env:
  - name: NODE_NAME
    valueFrom:
      fieldRef:
        fieldPath: spec.nodeName
  - name: NODE_IP
    valueFrom:
      fieldRef:
        fieldPath: status.hostIP
</code></pre>
<p>However, the documentation for the <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#envvarsource-v1-core" rel="nofollow noreferrer">EnvVarSource</a> API type notes that only a limited number of pod fields are supported.  Also note that these are injected into environment variables as strings, so there's no support for list-type values.</p>
<p>IME it's unusual for nodes to be directly exposed to the Internet.  You'd generally connect from the outside, to a load balancer in a DMZ, to a Kubernetes Service, to the pod.  In this case a pod would have no way of finding out the external DNS name, but it'd also be unlikely to change once configured, so you could inject it as a normal environment variable.</p>
