Created
February 4, 2021 22:25
-
-
Save warroyo/7b748947dfcfbe661c21fe511f1e4db2 to your computer and use it in GitHub Desktop.
getting a token from k8s service account
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
| export APISERVER=$(kubectl config view --minify | grep server | cut -f 2- -d ":" | tr -d " ") | |
| APISERVERNOHTTPS=$(echo $APISERVER | cut -c 9-) | |
| FPRINT=$(openssl s_client -connect $APISERVERNOHTTPS < /dev/null 2>/dev/null | openssl x509 -fingerprint -sha256 -noout -in /dev/stdin) | |
| export FINGERPRINT=$(echo $FPRINT | cut -c 20-) | |
| TOKENNAME=$(kubectl -n kube-system get serviceaccount/dev-admin -o jsonpath='{.secrets[0].name}') | |
| export TOKEN=$(kubectl -n kube-system get secret $TOKENNAME -o jsonpath='{.data.token}'| base64 --decode) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment