Start by running kubectl’s proxy. With its help, we avoid dealing 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 mores requests.
For cluster-scoped resources, use:
For namespace-scoped resources:
To get deployment data, for instance, 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 was 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>