Rancher Desktop port forwarding not working

2.3k Views Asked by At

I created a service exposing port 8000/TCP and trying to get that port forwarded to my Mac.

$ kubectl describe svc ddb
Name:              ddb
Namespace:         default
Labels:            <none>
Annotations:       <none>
Selector:          app=local-ddb
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                10.43.215.24
IPs:               10.43.215.24
Port:              <unset>  8000/TCP
TargetPort:        ddb-http-port/TCP
Endpoints:         10.42.0.91:8000
Session Affinity:  None
Events:            <none>

Port seems indeed open on my Mac (NOTE I found the local port number by looking at the Rancher Desktop GUI)

lsof | grep 56107
Rancher   50831 victorbarbu   84u     IPv4 0x8f04a06a4fb87541         0t0                 TCP localhost:56107 (LISTEN)

Doing curl http://localhost:56107 just hangs, however running:

$ kubectl run bb -i --tty --image alpine
# curl http://ddb:8000
{"__type":"com.[TRUNCATED]

Works as expected. Why could that be? How do I fix it?

1

There are 1 best solutions below

0
On

You are using a ClusterIp service type - that is for intra-cluster communication. This is why running curl from within a container works. Try using LoadBalancer or NodePort instead.

You can find more information in this article for example.