Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubernetes create service account token without expiration

Tags:

kubernetes

I created a token for my service account using the command 'kubectl create token admin-user'. But after a while it becomes unusable and I have to create it again. How can I generate a token for my service account without expire time?

like image 381
Content Avatar asked Oct 28 '25 03:10

Content


2 Answers

Try the token for one year using the below command. You can define duration as appropriate, say --duration=87600h for 10 years and so on

kubectl create token admin-user --duration=8760h
like image 121
P Ekambaram Avatar answered Oct 30 '25 18:10

P Ekambaram


As of v1.24, when using kubectl create token --duration it will not allow the creation of long lived tokens

This can be now be accomplished via the manual approach as explained in the official documentation.

https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#manually-create-a-long-lived-api-token-for-a-serviceaccount

like image 42
Sebastian Serrano Avatar answered Oct 30 '25 18:10

Sebastian Serrano



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!