Skip to content

Instantly share code, notes, and snippets.

@mgiacomini
Last active July 25, 2018 14:04
Show Gist options
  • Save mgiacomini/70a2829aa5d1fd11a583c422fa28e989 to your computer and use it in GitHub Desktop.
Save mgiacomini/70a2829aa5d1fd11a583c422fa28e989 to your computer and use it in GitHub Desktop.
How retrieve Kubernetes access token to current cluster (context)
# Check if the current cluster is right
kubectl config current-context
# Get the current context access token
TOKEN=$(kubectl describe secret $(kubectl get secrets | grep ^default | cut -f1 -d ' ') | grep -E '^token' | cut -f2 -d':' | tr -d " ")
# Print it :)
echo $TOKEN
# More info: https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment