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.
# List availabe contexts kubectl config get-contexts # Select the direct API context # Its name has the format <cluster_name>-<pilot_name> kubectl config use-context <direct_context>