Sometimes it’s useful or necessary to directly access the Kubernetes API server, for exploratory or testing purposes.
In order to do this, one option is to proxy the API to your local environment, using:
kubectl proxy --port=8080
Starting to serve on 127.0.0.1:8080
Now you can query the API (in a separate terminal session) like so:
curl http://localhost:8080/api/v1
{
"kind": "APIResourceList",
"groupVersion": "v1",
"resources": [
{
...
{
"name": "services/status",
"singularName": "",
"namespaced": true,
"kind": "Service",
"verbs": [
"get",
"patch",
"update"
]
}
]
}
Alternatively, without proxying, you can use kubectl
directly as follows to achieve the same:
kubectl get --raw /api/v1
Further, if you want to explore the supported API versions and/or resources, you can use the following commands:
kubectl api-versions
admissionregistration.k8s.io/v1beta1
...
v1
kubectl api-resources
NAME SHORTNAMES APIGROUP NAMESPACED KIND
bindings true Binding
componentstatuses cs false ComponentStatus
configmaps cm true ConfigMap
...