<p>I'm trying to use a <code>headless service</code> with an <code>endpoint</code> to forward traffic from within my cluster to my local development machine. I want to listen on port 80 on the service and call port 5002 on the endpoint. I have it setup as so:</p>
<p>Headless Service (listening on port 80 with a targetPort of 5002):
<a href="https://i.stack.imgur.com/D07hz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D07hz.png" alt="kubectl describe service web" /></a></p>
<p>Endpoint (pointing to my development computer on port 5002):
<a href="https://i.stack.imgur.com/C5frJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C5frJ.png" alt="kubectl describe endpoints web" /></a></p>
<p>When I try to <code>curl http://web:80</code> from any pod in my cluster on port 80 it times out. If I <code>curl http://web:5002</code> it successfully goes through and hits my development machine. Shouldn't the <code>targetPort</code> make the request to <code>web:80</code> go to my endpoint on port <code>5002</code>?</p>
<p><code>curl web:80</code>
<a href="https://i.stack.imgur.com/sP7z6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sP7z6.png" alt="curl web" /></a></p>
<p><code>curl web:5002</code>
<a href="https://i.stack.imgur.com/GWjQO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GWjQO.png" alt="curl web:5002" /></a></p>
<p>Some additional info:</p>
<ul>
<li>My cluster and dev machine are in the same local network</li>
<li>I'm using K3S on the cluster</li>
<li>I'm just trying to emulate what Bridge For Kubernetes does</li>
</ul>
<p>Here is the manifest yaml:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: web
  namespace: default
spec:
  clusterIP: None
  ports:
  - name: web
    port: 80
    targetPort: 5002
---
apiVersion: v1
kind: Endpoints
metadata:
  name: web
  namespace: default
subsets:
  - addresses:
      - ip: $HOST_IP
    ports:
      - name: web
        port: 5002
        protocol: TCP
</code></pre>

<p>I managed to get it to work by removing the <code>clusterIP: None</code>. My manifest now looks like this:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  type: ClusterIP
  ports:
  - name: web
    port: 80
    targetPort: 5002
---
apiVersion: v1
kind: Endpoints
metadata:
  name: web
subsets:
  - addresses:
      - ip: $HOST_IP
    ports:
      - name: web
        port: 5002
</code></pre>
