Difference between revisions of "Access Kubernetes REST API using default token"
Jump to navigation
Jump to search
↑ https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/
(3 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
TOKEN=$([[kubectl describe secret default-token]] | grep -E '^token' | cut -f2 -d':' | tr -d " ") | TOKEN=$([[kubectl describe secret default-token]] | grep -E '^token' | cut -f2 -d':' | tr -d " ") | ||
− | [[curl]] $APISERVER[[/api]] [[--header]] "[[Authorization: Bearer]] $TOKEN" --insecure | + | [[curl]] $APISERVER[[/api]] [[--header]] "[[Authorization: Bearer]] $TOKEN" --insecure <ref> https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/</ref> |
− | |||
+ | You can use a default-token or generate one in EKS using: <code>aws eks get-token</code> | ||
+ | == Examples == | ||
{"type":"error","status":"[[401]]","message":"[[Unauthorized 401: must authenticate]]"} | {"type":"error","status":"[[401]]","message":"[[Unauthorized 401: must authenticate]]"} | ||
Line 30: | Line 31: | ||
* [[curl http://localhost:8080/api/]] | * [[curl http://localhost:8080/api/]] | ||
* [[curl --header]] | * [[curl --header]] | ||
+ | * [[Access EKS API using a Bearer token]] | ||
== See also == | == See also == |
Latest revision as of 17:13, 24 October 2023
APISERVER=$(kubectl config view --minify | grep server | cut -f 2- -d ":" | tr -d " ") TOKEN=$(kubectl describe secret default-token | grep -E '^token' | cut -f2 -d':' | tr -d " ") curl $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure [1]
You can use a default-token or generate one in EKS using: aws eks get-token
Contents
Examples[edit]
{"type":"error","status":"401","message":"Unauthorized 401: must authenticate"}
{ "kind": "APIVersions", "versions": [ "v1" ], "serverAddressByClientCIDRs": [ { "clientCIDR": "0.0.0.0/0", "serverAddress": "ip-172-16-37-214.ec2.internal:443" } ] }%
Errors[edit]
Error from server (NotFound): secrets "default-token" not found
Related[edit]
- Kubernetes bearer tokens
Content-Type: application/json
- curl http://localhost:8080/api/
- curl --header
- Access EKS API using a Bearer token
See also[edit]
- Kubernetes API, Kubernetes API server, EKS API,
apiVersion:, kubectl api-resources, kubectl api-versions, kind:
, Kubernetes API endpoint, 6443, 10250 (kubelet)kube-apiserver
, /etc/kubernetes/manifests/kube-apiserver.yaml,valueFrom, /var/log/kube-apiserver.log, /api/v1/, k8s.io
Advertising: