简体   繁体   中英

Kubernetes Dashboard: Token authentication not showing

I'm trying to get the Kubernetes Dashboard Auth token using the following command:

kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')

But there is nothing, I followed this article and this is the response without the grep: Screenshot

I was able to get the token using the command:

kubectl -n kubernetes-dashboard get secrets/admin-user-secret -o jsonpath="{.data.token}"

Also be aware about LegacyServiceAccountTokenNoAutoGeneration, that's why there are no any token autogeneration no more starting from 1.24 https://github.com/kubernetes/kubernetes/issues/110113 . So now we need to manually create a service account API token https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#manually-create-a-service-account-api-token

From K8s 1.24, secret created by K8s using serviceaccount token will not created. You can create serviceaccount token manually

kubectl create token SERVICE_ACCOUNT_NAME -n <namepace>

You can set the token duration by setting the duration parameter like

kubectl create token myapp --duration 10m

This will create the token for 10 minutes, default is 0s. From the docs: Default duration is 0s. Duration means Requested lifetime of the issued token. The server may return a token with a longer or shorter lifetime. | https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-token-em-

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM