How to Configure Kubeconfig based login in Kubernetes Dashboard

5/15/2019

I have configured Kubernetics has 4 node cluster and configured Dashboard from Kubernetics Documentation but able to login with different Token based service account which have different role bind on that account .

But my point is I want to login with Kubeconfig options but I am unable to do so . So help me the steps how to do that. enter image description here

-- Way Fun
devops
docker
google-cloud-platform
kubernetes
kubernetes-dashboard

1 Answer

5/17/2019

Finally found this answer after search number of sites .

$ TOKEN=$(kubectl -n kube-system describe secret default| awk '$1=="token:"{print $2}')
$ kubectl config set-credentials kubernetes-admin --token="${TOKEN}"

Your config file should be looking like this:

$ kubectl config view |cut -c1-50|tail -10
name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED
    token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.ey
-- Way Fun
Source: StackOverflow