Friday, 9 March 2018

How to enable Kubernetes dashboard


Aim:

To enable Kubernetes cluster dashboard. 

Steps:


Please follow below steps to enable the dashboard:

kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml

With the above command, the dashboard will be available but only with very minimal privileges.
This is because of security issues.

However, if you want to grant full admin privileges, you can follow below steps:
(Be aware it is not recommended in a PROD cluster, this is just for learning purpose.)

Create a 'dashboard-admin.yaml' file with following content:

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: kubernetes-dashboard
  labels:
    k8s-app: kubernetes-dashboard
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: kubernetes-dashboard
  namespace: kube-system

Execute the below command:

kubectl create -f dashboard-admin.yaml

At this point, kuernetes dashboard is up and running with admin privileges.
However, it will not be accessible outside of your cluster.
To make it available to outside world, execute the following:

[1] kubectl -n kube-system edit service kubernetes-dashboard

Change 'type: ClusterIp' to 'type: NodePort'.

[2] kubectl -n kube-system get service kubernetes-dashboard

[root@vmdocc7176 ~]# kubectl -n kube-system get service kubernetes-dashboard
NAME                   TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)         AGE
kubernetes-dashboard   NodePort   10.115.144.121   <none>        443:32227/TCP   12m


Now you can access the kubernetes dashboard using the following URL:
https://<API Server IP>:32227




No comments:

Post a Comment