Accessing the OpenAPI Specification for a Kubernetes Cluster
I'm a big fan of working with OpenAPI specifications, and while working with Kubernetes APIs today I wanted to check what the API expected.
Fortunately, Kubernetes produces the cluster's supported OpenAPI at the /openapi/v2
URL, which means that using Jonny Langefeld's post we can use kubectl proxy
to port-forward, and then grab a copy of the OpenAPI:
kubectl proxy --port=8080
curl localhost:8080/openapi/v2 > openapi.json
This can then be used with your favourite OpenAPI viewer, such as a local-only, client-side viewer to give you handy API documentation.