Kubernetes and curl: Difference between revisions
Jump to navigation
Jump to search
Line 6: | Line 6: | ||
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token); \ | TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token); \ | ||
curl -sSk -H "Authorization: Bearer ${TOKEN}" https | curl -sSk -H "Authorization: Bearer ${TOKEN}" https://kubernetes.default/api/v1/namespaces/ | ||
[[Curl#-k_--insecure|-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: | [[Curl#-k_--insecure|-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: | ||
Line 13: | Line 13: | ||
curl -sS -H "Authorization: Bearer ${TOKEN}" \ | curl -sS -H "Authorization: Bearer ${TOKEN}" \ | ||
--cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \ | --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \ | ||
https | https://kubernetes.default/api/v1/namespaces/ |
Revision as of 17:01, 13 September 2019
Internal
Invoking into the API Server from Inside a Pod
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token); \ curl -sSk -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 -sS -H "Authorization: Bearer ${TOKEN}" \ --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \ https://kubernetes.default/api/v1/namespaces/