<p>Following the example on <a href="https://kubernetes.io/docs/concepts/services-networking/service/#services-without-selectors" rel="nofollow noreferrer">kubernetes.io</a> I'm trying to connect to an external IP from within the cluster (and i need some port proxy, so not ExternalName service). However it is not working. This is the response I'm expecting</p>
<pre class="lang-bash prettyprint-override"><code>ubuntu:/opt$ curl http://216.58.208.110:80
&lt;HTML&gt;&lt;HEAD&gt;&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html;charset=utf-8&quot;&gt;
&lt;TITLE&gt;301 Moved&lt;/TITLE&gt;&lt;/HEAD&gt;&lt;BODY&gt;
&lt;H1&gt;301 Moved&lt;/H1&gt;
The document has moved
&lt;A HREF=&quot;http://www.google.com/&quot;&gt;here&lt;/A&gt;.
&lt;/BODY&gt;&lt;/HTML&gt;
</code></pre>
<p>if I use the following config</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
  name: my-service-1
  labels:
    kubernetes.io/service-name: my-service
addressType: IPv4
ports:
  - name: http
    appProtocol: http
    protocol: TCP 
    port: 80
endpoints:
  - addresses:
      - &quot;216.58.208.110&quot;
---
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  ports:
    - protocol: TCP 
      port: 8888
      targetPort: 80
</code></pre>
<p>I expect the following command to get same result:</p>
<pre class="lang-bash prettyprint-override"><code>minikube kubectl -- run -it --rm --restart=Never curl --image=curlimages/curl curl -- my-service:8888
</code></pre>
<p>but I get nothing.
if I start an debian image with</p>
<pre class="lang-bash prettyprint-override"><code>minikube kubectl -- run -it --rm --restart=Never debian --image=debian:latest
</code></pre>
<p>then</p>
<pre class="lang-bash prettyprint-override"><code>apt update &amp;&amp; apt install dnsutils curl -y &amp;&amp; nslookup my-service &amp;&amp; curl my-service:8888
</code></pre>
<p>gives</p>
<pre class="lang-bash prettyprint-override"><code>Server:     10.96.0.10
Address:    10.96.0.10#53

Name:   my-service.default.svc.cluster.local
Address: 10.111.116.160
curl: (28) Failed to connect to my-service port 8888: Connection timed out
</code></pre>
<p>Am i missing something? or is it not supposed to work this way?</p>

<p>After some trial and error it seem that if <code>ports[0].name = http</code> is set for the <code>endpointslice</code> it stops working.</p>
<p>it stops working for when for the <code>service</code> <code>spec.ports[0].targetPort</code> is set to <code>80</code> or <code>http</code> as well.</p>
<p>(it does work when <code>ports[0].name = ''</code>)</p>
<p>Further investing shows that it works if:</p>
<p>for <code>service</code></p>
<pre class="lang-yaml prettyprint-override"><code>spec:
  ports:
  - port: 8888
    name: http
    targetPort: http
</code></pre>
<p>for <code>endpointslice</code></p>
<pre class="lang-yaml prettyprint-override"><code>ports:
  - port: 80
    name: http
</code></pre>
<p>I guess if you want to name them both the <code>service</code> and the <code>endpointslice</code> have to have corresponding <code>.name</code> values.</p>
