简体   繁体   中英

How to reach openapi interface for minikube?

According to Kubernetes documentation , you can ping an http endpoint for a K8s cluster to operate it instead of using eg kubectl . It also says that there is an openApi interface available at /openapi/v2 . I'm running minikube on MacOS and would like to check it out. Does anyone know if that is possible?

I tried:

minikube list service # Shows 'kubernetes' as a name
minikube list kubernetes

... which opens the browser to 127.0.0.1:51377 . However, when I try going to https://127.0.0.1:51377/openapi/v2 I get the message:

{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "forbidden: User \"system:anonymous\" cannot get path \"/openapi/v2\"",
"reason": "Forbidden",
"details": {},
"code": 403
}

... suggesting that I need some sort of authorization solution. Suggestions?

This worked for me:

# Proxy minikube to localhost on arbitrary port:
kubectl proxy --port=12345

# Now swagger.json is available at localhost:12345/openapi/v2
# Save to /tmp/temp/json and serve with e.g. docker swagger-ui container
curl localhost:12345/openapi/v2 > /tmp/temp.json
docker run -it -p 9999:8080 -e SWAGGER_JSON=/var/specs/temp.json -v /tmp/temp.json:/var/specs/temp.json swaggerapi/swagger-ui

# Open browser to localhost:9999

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM