How to access Kubernetes using REST API
Using proxy
kubectl proxy
# or to allow access from all interfaces
kubectl proxy --address=0.0.0.0 --accept-hosts='.*'
curl localhost:8001
By passing token in request header
-
Get token from output of
kubectl get secrets -o yaml
-
Get api url from output of
kubectl config view # OR kubectl cluster-info
e.g. https://192.168.121.54:6443
-
Fire the request
curl -k --header "Authorization: Bearer ${TOKEN}" ${API_URL}
Details in Accessing Cluster