Open bobjackman opened 4 years ago
This sort of port forwarding seems to work fine for other services in my stack, but not this one. Does it maybe have something to do with the nodePort
declaration? (my other services don't have this)
I think I basically understand what's happening here.
Under the hood, port-forwarding only acts on pods. It never acts on deployments, or on services, or on anything else.
This bites people all the time because lots of tools (kubectl, tilt) offer a UX of port-forwarding on arbitrarily high-level resources, but under the hood, they're just resolving the resource to a pod and port-forwarding to that.
What's happening in the first few examples is that you didn't provide a target port, so tilt looks through the pod spec and just port-forwards to the first port on the pod -- which in your case, is probably 8080.
When you specify target port 80, Tilt tries to port-forward to port 80 on the pod -- not the service
I still think there's a bug here -- e.g., Tilt should be able to tell you when you made this kind of mistake.
Ohh, tilt maps to the container port -- that's really good to know!
When a target port isn't defined, is there a way to see what Tilt auto-resolved it to?
So, maybe I'm not understanding your explanation like I thought I did. Based on what you said, I tried targeting the containerPort of the pod (bypassing the service entirely)...
k8s_resource('blah', port_forwards=['9999:8080']) # doesn't work 😢
So then I tried removing my targetPort, to let Tilt resolve it automatically...
k8s_resource('blah', port_forwards=['9999']) # doesn't work 😢
@nicks actually, scratch that. Now that I'm targeting the container port (not the service port), it's actually working as expected!
I only thought it wasn't working because, as it turns out, I was making my test request on the right host/port, but the rest of the request was bad. I was getting an empty response from the server that made it just look like the port forwarding was busted.
deployed k8s service: