Bug 1330006

Summary: The api entry "/api/v1/namespaces/<namespace name>/services/<service name>/proxy/" do not work
Product: OKD Reporter: weiwei jiang <wjiang>
Component: PodAssignee: Andy Goldstein <agoldste>
Status: CLOSED CURRENTRELEASE QA Contact: DeShuai Ma <dma>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.xCC: aos-bugs, mmccomas, sross, wjiang, wsun
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-09-19 13:50:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description weiwei jiang 2016-04-25 09:31:10 UTC
Description of problem:
After I create a hello-openshift app via `oc new-app openshift/hello-openshift:latest --name=hello-openshift`, got "no endpoints available for service \"hello-openshift\"" when try to access the "/api/v1/namespaces/<namespace name>/services/<service name>/proxy/" with bearer token.
And the pod/proxy work well 
# curl -k https://127.0.0.1:8443/api/v1/namespaces/wjiang/pods/hello-openshift-1-we1f4/proxy/                                             
Hello OpenShift!

# oc get endpoints
NAME              ENDPOINTS                         AGE
hello-openshift   172.17.0.5:8080,172.17.0.5:8888   12m


Version-Release number of selected component (if applicable):
devenv-rhel7_4020

How reproducible:
always

Steps to Reproduce:
1. Create an app
oc new-app openshift/hello-openshift:latest --name=hello-openshift
2. Grant admin role to system:anonymouns user
oc policy add-role-to-user admin system:anonymouns
3. Try to curl the api 
curl -k https://<master host>:8443/api/v1/namespaces/<namespace name>/services/<service name>/proxy/

Actual results:
# curl -k https://127.0.0.1:8443/api/v1/namespaces/wjiang/services/hello-openshift/proxy/
{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {},
  "status": "Failure",
  "message": "no endpoints available for service \"hello-openshift\"",
  "reason": "ServiceUnavailable",
  "code": 503
}

Expected results:
Hello OpenShift!

Additional info:

Comment 1 Solly Ross 2016-04-25 15:08:13 UTC
The hello-openshift app's service is set up to serve on port 8080.  Ergo, you'd need the following url to properly proxy to it:

http://localhost:8443/api/v1/namespaces/proxy-test/services/http:hello-openshift:8080/proxy/

Comment 2 weiwei jiang 2016-04-26 02:32:33 UTC
{(In reply to Solly Ross from comment #1)
> The hello-openshift app's service is set up to serve on port 8080.  Ergo,
> you'd need the following url to properly proxy to it:
> 
> http://localhost:8443/api/v1/namespaces/proxy-test/services/http:hello-
> openshift:8080/proxy/


Checked with devenv-rhel7_4026, the works well with the api entry.

But then we have to update the swaggerapi doc, since I use the api according to the doc, it said that the parameter is the "name of the Service", and even the kubernetes official doc http://kubernetes.io/docs/api-reference/v1/operations/

{
"path": "/api/v1/namespaces/{namespace}/services/{name}/proxy",
"description": "API at /api/v1",
"operations": [
{
"type": "string",
"method": "GET",
"summary": "connect GET requests to proxy of Service",
"nickname": "connectGetNamespacedServiceProxy",
"parameters": [
{
"type": "string",
"paramType": "query",
"name": "path",
"description": "Path is the part of URLs that include service endpoints, suffixes, and parameters to use for the current proxy request to service. For example, the whole request URL is http://localhost/api/v1/namespaces/kube-system/services/elasticsearch-logging/_search?q=user:kimchy. Path is _search?q=user:kimchy.",
"required": false,
"allowMultiple": false
},
{
"type": "string",
"paramType": "path",
"name": "namespace",
"description": "object name and auth scope, such as for teams and projects",
"required": true,
"allowMultiple": false
},
{
"type": "string",
"paramType": "path",
"name": "name",
"description": "name of the Service",
"required": true,
"allowMultiple": false
}
],
"produces": [
"*/*"
],
"consumes": [
"*/*"
]
},

Comment 3 Andy Goldstein 2016-04-26 13:46:32 UTC
Please mark this VERIFIED and open a new bug for the Swagger issue

Comment 4 weiwei jiang 2016-04-27 01:52:49 UTC
(In reply to Andy Goldstein from comment #3)
> Please mark this VERIFIED and open a new bug for the Swagger issue

Ok, will draft a new bug for the swagger issue.