<p>I've deployed the Rancher Helm chart to my Kubernetes cluster and want to access the Rancher API/UI from another pod (i.e. a pod running an ingress-controller). </p>

<p>when I list the services and the endpoints. The IP addresses differ:</p>

<pre><code>$ kubectl get ep | grep rancher
release-name-rancher                         10.200.23.13:80                    18h
</code></pre>

<p>and </p>

<pre><code>$ kubectl get services | grep rancher 
release-name-rancher                         ClusterIP   10.100.200.253   &lt;none&gt;        80/TCP                       18h
</code></pre>

<p>Within the container of the client (i.e. the ingress controller), I see the service beeing represented with the service's ClusterIP:</p>

<pre><code>$ env | grep RELEASE_NAME_RANCHER_SERVICE_HOST
RELEASE_NAME_RANCHER_SERVICE_HOST=10.100.200.253
</code></pre>

<p>Trying to reach the backend via the IP address in the Env does not work (<code>curl 10.100.200.253</code> just delivers no response and blocks forever). </p>

<p>Trying to reach the backend via the endpoint address works:</p>

<pre><code>$ curl 10.200.23.13
&lt;a href="https://10.200.23.13/"&gt;Found&lt;/a&gt;.
</code></pre>

<p><strong>I'm quite confused why the endpoint IP address and the ClusterIP address differ and why is it not possible to connect to the ClusterIP address. Any hints to polish my understanding?</strong></p>

Oliver Wolf
<p>In Kubernetes, every Pod and Service gets its own IP address.  The <code>kubectl get services</code> IP address is the Kubernetes-internal address of the Service; the <code>get ep</code> address address of the Pod behind it.  The Service actually acts like a load balancer, and there can be multiple Pods attached to it.  The <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Kubernetes Service documentation</a> goes into a <em>lot</em> of detail about what exactly is happening here.</p>

<p>Kubernetes also provides an <a href="https://kubernetes.io/docs/concepts/services-networking/service/#dns" rel="nofollow noreferrer">internal DNS service</a> that can resolve Service names.  You generally shouldn't use any of these IP addresses directly; instead, use the host name <code>release-name-rancher.default.svc.cluster.local</code> (or replace "default" if you're running in some other Kubernetes namespace).</p>

<p>While the <code>..._SERVICE_HOST</code> environment variable you reference is supported and documented, I'd avoid using it.  Of particular note, if you <code>helm install</code> or <code>kubectl apply</code> a large set of resources at once and the Pod gets created before the Service, you'll be in a consistent state except that the Pod won't actually have this environment variable.  In a Helm land where Services don't have fixed names, the environment variable name won't be fixed either.  Prefer the DNS name.</p>
