Wednesday, July 1, 2020

Configure Kebernetes dashboard from our local machines

on mgnt server:

kubectl apply -f
https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.1/aio/deploy/recommended.yaml


kubectl get pod -n kubernetes-dashboard

on windows cmd:

copy the .kube/config file from mgnt server to windows kubectl path.

C:\Users\Hariom>kubectl.exe --kubeconfig=kubeconfig.txt get pods -n kubernetes-dashboard
NAME                                         READY   STATUS    RESTARTS   AGE
dashboard-metrics-scraper-6b4884c9d5-ddwvx   1/1     Running   0          31m
kubernetes-dashboard-7bfbb48676-9jgp6        1/1     Running   0          31m

on mgnt server we have to create role and binding related to dashboard:

create 2 yamls for role and bindings


echo 'apiVersion: v1
kind: ServiceAccount
metadata:
 name: admin-user
 namespace: kubernetes-dashboard' |kubectl create -f -
--------
echo 'apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
 name: admin-user
roleRef:
 apiGroup: rbac.authorization.k8s.io
 kind: ClusterRole
 name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kubernetes-dashboard' |kubectl create -f -

  • on CMD we need to execute the below command.
C:\Users\Hariom>kubectl.exe --kubeconfig=kubeconfig.txt  proxy http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
  • go to browser and access the url: http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login
        and it will ask for Token just go to mgnt server and create the token by command:
 kubectl -n kubernetes-dashboard describe secret $(kubectl -n kubernetes-dashboard get secret | grep admin-user | awk '{print $1}')
 copy the token and paste it in the browser and click on Signin