Last active
December 1, 2021 19:41
-
-
Save amcginlay/2a74c428886d91122fa51e0d2b39b47a to your computer and use it in GitHub Desktop.
eks-get-token.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# inspired by https://www.youtube.com/watch?v=4l4Kuds8O3s | |
cluster=dev | |
# grab the k8s api server endpoint and the encoded authentication token | |
eks_token=$(aws eks get-token --cluster-name ${cluster} | jq .status.token --raw-output) | |
eks_endpoint=$(aws eks describe-cluster --name ${cluster} | jq .cluster.endpoint --raw-output) | |
# decode the token to see what's going on under the hood (this patially fails but the essential details are clear) | |
echo ${eks_token} | cut -d. -f2 | base64 --decode | |
# send a request to the endpoint which returns a list of methods | |
curl -k -H "x-k8s-aws-id: ${cluster}" -H "Authorization: Bearer ${eks_token}" ${eks_endpoint} | |
# hit the /version method | |
curl -k -H "x-k8s-aws-id: ${cluster}" -H "Authorization: Bearer ${eks_token}" ${eks_endpoint}/version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment