Start by using kubectl’s proxy to make the requests. This avoids having to deal with authentication headers.
Test the connection with a basic call.
To check the APIs groups available, access the root.
Based on the groups list, you can create the URLs for next requests.
For cluster-scoped resources, use:
For namespace-scoped resources:
To get deployment data, the API Group is “apps”, Version is “v1” and Resourcetype is “deployments”. The final request looks like this:
If the Kubernetes cluster has a metrics-server, the following request will get node resource usage data:
However, if your cluster has been created using Rancher, you need to have “Authorized Cluster Endpoint” activated, so your requests can reach the API Server directly. If not, your URL paths will differ from the examples above.
On your command line, you will also have to select the correct context for
kubectl before activating the proxy.
kubectl config get-contexts
kubectl config use-context <direct_context>
Overview of the Kubernetes API
More info about API concepts
Accessing the API without kubectl proxy
Full list of Groups, Versions and Resourcetypes