1

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
  • 109
  • 2
  • 7
  • You access the dashboard with your browser and your browser cannot access your kubeconfig. You can only configure kubeconfig to be able to run kubectl commands on your cluster. Is that what you mean? – Mihai May 15 '19 at 05:43
  • No @Mihai actually I want to login Dashboard using Kubeconfig option with choose kubeconfig file . How to make that file so that I can access dashboard. – Way Fun May 15 '19 at 05:49
  • I understand now. Can you already run kubectl commands from your station and connect to cluster? – Mihai May 15 '19 at 05:53
  • @Mihai Not till now , I usually run kubectl from master node only . Till now doing all the task on master node directly . – Way Fun May 15 '19 at 05:56
  • Then you should copy the kubeconfig from master into your local and change the URL to point to your server and port where the app is running (basically the base URL you use for the dashboard) – Mihai May 15 '19 at 05:59
  • @Mihai Yes but where to find Kubeconfig file , Is it /root/.kube/config file ? which file contain cluster: certificate-authority-data – Way Fun May 15 '19 at 06:04
  • Yes that is the file. You have to copy the whole file in your local at ~/.kube/config. The only thing to change is the URL, leave the certificates as they are – Mihai May 15 '19 at 06:07
  • @Mihai and all I am getting error **"Not enough data to create auth info structure"** while trying to access Kubernetes Dashboard. – Way Fun May 16 '19 at 10:42

1 Answers1

2

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
CryogenicNeo
  • 937
  • 12
  • 25
Way Fun
  • 109
  • 2
  • 7
  • If I try to upload the config file to the dashboard nothing happens. No error message, nothing. – Michael Dec 11 '20 at 12:48