Prerequisites: Kubernetes cluster and local kubectl configuration
- Look for which service account you want to use
$ kubectl -n kube-system get serviceaccount
- Retrieve the token name
$ TOKENNAME=`kubectl -n kube-system get serviceaccount/[INSERT SERVICE ACCOUNT NAME] -o jsonpath='{.secrets[0].name}'`
- Retrieve the base64 encoded token value.
$ kubectl -n kube-system get secret $TOKENNAME -o jsonpath='{.data.token}' | base64 --decode