Reputation: 1
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
Upvotes: 0
Views: 3876
Reputation: 317
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-
Upvotes: 4
Reputation: 21
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
Upvotes: 2