Reputation: 1605
I'm trying to use a headless service
with an endpoint
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:
Headless Service (listening on port 80 with a targetPort of 5002):
Endpoint (pointing to my development computer on port 5002):
When I try to curl http://web:80
from any pod in my cluster on port 80 it times out. If I curl http://web:5002
it successfully goes through and hits my development machine. Shouldn't the targetPort
make the request to web:80
go to my endpoint on port 5002
?
Some additional info:
Here is the manifest yaml:
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
Upvotes: 1
Views: 535
Reputation: 1605
I managed to get it to work by removing the clusterIP: None
. My manifest now looks like this:
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
Upvotes: 1