kubernetes – how to view the contents of a secret token

  kuberenetes
# run a generic pod
k run pod1 --image=busybox

# get the secret out of the pod, into a local file called token
k exec -it pod1 -- cat /var/run/secrets/kubernetes.io/serviceaccount/token > token

# install jq utility
sudo apt-get install jq -y

# view the token using jq:
jq -R 'split(".") | select(length > 0) | .[0],.[1] | @base64d | fromjson' \
 <<< `cat token`
Example output.