access-tokenk3skubernetes-dashboard

Use static token while login into kubernetes dashboard


I have setup k3s. Also I have setup kubernetes-dashboard on k3s.

But I want to use static token while login into the kubernetes dashboard. I does not want to use different token each time when I setup k3s and kubernetes-dashboard.

I found this link for using user/pass in kubernetes. Similarly I want to use static token for kubernetes dashboard in k3s setup.

Is there any way to do this?


Solution

  • Based on my findings we need to create file(token.csv) which contains password/token:

     admin123 admin admin system:masters
    

    After that while installing k3s we can pass this file:

    curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.21.8+k3s1 sh -s - --kube-apiserver-arg='token-auth-file=/home/ubuntu/token.csv'
    

    After that we can use the token "admin123" to login into kubernetes dashboard.