You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
using targetPort with a name in service definition doesn't seem to work via route #6265
Using targetPort in the service definition to map to a named port in a pod definition doesn't seem to work. Everything looks like it works and the web interface even has 80/TCP → apacheport in the display, but I can never establish a connection. If I instead use targetPort : 8080 in openshift it works. Mapping to a name works in kubernetes-1.1.0-0.17.git388061f.fc23.x86_64 so I think I'm not doing something wrong, but I can't be sure. My target ose environment is 3.1.
Does #5578 actually fix the issue with named ports, or just let you set a numeric target port on the route. Named ports are needed when you want services or routes to route to different port numbers on pods that are serving the same content.
For that to work, the names of the ports need to make it into the endpoints somehow. Isn't that an upstream bug that needs fixing?
I think that the problem is this. Which is an upstream bug, yes. In the meantime, making oc expose set a numeric target port (I dont think users generate routes manually any more) and beefing up oc status to report (even if we fix endpoints upstream, we probably still want the oc status changes) seems fine?
It just seems like the route is picking up the name of the pod port, when that is not what will be surfaced in the endpoint. In this case, the route should have been using the endpoint port named "", right?
It just seems like the route is picking up the name of the pod port, when that is not what will be surfaced in the endpoint. In this case, the route should have been using the endpoint port named "", right?
I am not sure about that. Maybe @pweil- can weigh in
if a route has a numeric targetPort, that matches the containerport number.
if a route has a named targetPort, that matches the serviceport name (NOT the containerport name)
My preference would be to switch routes to use the serviceport names, so that changes to the service port mapping get picked up by the route automatically.
@Kargakis@spadgett I think we should change oc expose and the UI route creation to set a route's targetPort to the name of the service port by default.
We could also look into requesting that the service port number be added to the endpoint info, which would give us a chance of letting a routeport numeric targetPort map to a service port number without needing to watch services as well
changed the title [-]using targetPort with a name in service definition doesn't seem to work[/-][+]using targetPort with a name in service definition doesn't seem to work via route[/+]on Dec 11, 2015
I can confirm that this is still an issue. The actual behavior does not match the expected, and doesn't make sense. If we define a targetPort: , that should match to a containerPort name on the pod.
Yes. Same too. IDK why but I viewed the service port from container and find that it's can connect.
So it's not caused by connection problem of services.
I find that this only happen when port of service is different from container's.
if a route has a numeric targetPort, that matches the containerport number.
if a route has a named targetPort, that matches the serviceport name (NOT the containerport name)
But when create route from web console the number port selected is the service port.
e.g the page shows 80->1234 then route use 80 port of service.
Activity
liggitt commentedon Dec 10, 2015
How are you attempting to establish the connection?
dustymabe commentedon Dec 10, 2015
curl or firefox, neither work. I always get a 503 error
liggitt commentedon Dec 10, 2015
What do the endpoints for the service look like?
liggitt commentedon Dec 10, 2015
and you are curling the service ip directly, not going through the API proxy, right?
dustymabe commentedon Dec 10, 2015
I am curling the hostname associated with the route that is associated with the service.
route info
service info
endpoints info
dustymabe commentedon Dec 10, 2015
Note that the route was created using
./oc expose service apacheservice0xmichalis commentedon Dec 10, 2015
The problem is that the route uses a named target port and the associated endpoint is not. #5578 fixes this.
0xmichalis commentedon Dec 10, 2015
In the meantime, @dustymabe can you try
and try to connect?
dustymabe commentedon Dec 10, 2015
@Kargakis that patch command works
liggitt commentedon Dec 11, 2015
Does #5578 actually fix the issue with named ports, or just let you set a numeric target port on the route. Named ports are needed when you want services or routes to route to different port numbers on pods that are serving the same content.
For that to work, the names of the ports need to make it into the endpoints somehow. Isn't that an upstream bug that needs fixing?
0xmichalis commentedon Dec 11, 2015
I think that the problem is this. Which is an upstream bug, yes. In the meantime, making oc expose set a numeric target port (I dont think users generate routes manually any more) and beefing up oc status to report (even if we fix endpoints upstream, we probably still want the oc status changes) seems fine?
liggitt commentedon Dec 11, 2015
It just seems like the route is picking up the name of the pod port, when that is not what will be surfaced in the endpoint. In this case, the route should have been using the endpoint port named "", right?
0xmichalis commentedon Dec 11, 2015
I am not sure about that. Maybe @pweil- can weigh in
pweil- commentedon Dec 11, 2015
Routes use endpoints and filter based on the endpoint name.
how endpoints are given to the router: https://github.com/openshift/origin/blob/master/plugins/router/template/plugin.go#L194-194
how the router filters them with a preferred port:
https://github.com/openshift/origin/blob/master/plugins/router/template/router.go#L364-364
https://github.com/openshift/origin/blob/master/plugins/router/template/router.go#L148-148
cc @ramr
liggitt commentedon Dec 11, 2015
Summary:
My preference would be to switch routes to use the serviceport names, so that changes to the service port mapping get picked up by the route automatically.
@Kargakis @spadgett I think we should change
oc exposeand the UI route creation to set a route's targetPort to the name of the service port by default.We could also look into requesting that the service port number be added to the endpoint info, which would give us a chance of letting a routeport numeric targetPort map to a service port number without needing to watch services as well
7 remaining items
[-]using targetPort with a name in service definition doesn't seem to work[/-][+]using targetPort with a name in service definition doesn't seem to work via route[/+]redis: workaround openshift bug with service definitions
guestbook: workaround openshift bug with service definitions
thincal commentedon Jan 20, 2016
but, if a route without the targetPort, which port will be matched if the service/pod with more than one port defined ? thanks.
liggitt commentedon Jan 20, 2016
The route round-robins among all the service ports.
thincal commentedon Jan 20, 2016
if there are more than one port could serve the request, which will be selected eventually ? just randomly ?
liggitt commentedon Jan 20, 2016
It is effectively random, yes. That behavior is probably not what you want... in most cases, the route should target a specific port
gWOLF3 commentedon Dec 31, 2019
I can confirm that this is still an issue. The actual behavior does not match the expected, and doesn't make sense. If we define a targetPort: , that should match to a containerPort name on the pod.
gWOLF3 commentedon Dec 31, 2019
/bump
k79e commentedon Mar 11, 2020
Yes. Same too. IDK why but I viewed the service port from container and find that it's can connect.
So it's not caused by connection problem of services.
I find that this only happen when port of service is different from container's.
I don't use port name but the number.
k79e commentedon Mar 11, 2020
But when create route from web console the number port selected is the service port.
e.g the page shows 80->1234 then route use 80 port of service.