<p><a href="https://i.stack.imgur.com/Ctb2f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ctb2f.png" alt="enter image description here"></a></p>

<p>Why sometimes kubernetes has 2 internal endpoints for a service, sometimes 4?
why do the internal endpoints always come in pairs?</p>

Suicide Bunny
<p>This is based on my loose understanding of things and an assumption. The assumption is that this seems to be the case when the cluster is deployed to GKE.</p>

<p>Since I don't have Kafka manager installed, I will use the example of Kubernetes service, which has a similar port configuration in the console. This service is of type <code>ClusterIP</code></p>

<pre><code>Name         Cluster IP     Internal Endpoints
Kubernetes   10.11.240.1    kubernetes:443 TCP
                            kubernetes:0 TCP
</code></pre>

<p>The port 0 is added by GKE Ingress to randomly select a port for forwarding, as <a href="https://stackoverflow.com/questions/48814326/what-is-port-0-used-for-in-kubernetes-services">explained here</a> and also related <a href="https://stackoverflow.com/questions/45738404/gce-loadbalancer-invalid-value-for-field-namedports0-port-0-must-be-gr/45974827#45974827">discussion here</a></p>

<p>In case of NodePort service, it is a different story. </p>

<pre><code>Name         Cluster IP     Internal Endpoints
hello-web    10.11.249.126  helloweb:8080 TCP
                            helloweb:30193 TCP
</code></pre>

<p>This can be also seen in the service description. Since service is already exposed on a nodeport, there is no need to additionally expose on a random port.</p>

<pre><code>$kubectl describe service helloweb-backend -n default
Name:           helloweb-backend
Type:           NodePort
IP:             10.11.249.126
Port:           &lt;unset&gt; 8080/TCP
NodePort:       &lt;unset&gt; 30193/TCP
Endpoints:      10.8.3.3:8080
</code></pre>
