Kubernetes and curl

From NovaOrdis Knowledge Base
Revision as of 17:02, 13 September 2019 by Ovidiu (talk | contribs) (→‎Invoking into the API Server from Inside a Pod)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Invoking into the API Server from Inside a Pod

TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token); \
curl -Sk -H "Authorization: Bearer ${TOKEN}" \
https://kubernetes.default/api/v1/namespaces/

-k in the command above instructs curl to execute in insecure mode. We can actually run it in secure mode because we have access to the certificate:

TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token); \
curl -S -H "Authorization: Bearer ${TOKEN}" \
--cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \
https://kubernetes.default/api/v1/namespaces/