Steps to Install Kubernetes Dashboard

Steps to Install Kubernetes Dashboard

In this blog, we will show you the Steps to Install Kubernetes Dashboard in your environment.

 

REQUIREMENTS

  • 2 Node Cluster ( 1 Master VM with 2 Nodes)
  • Kubernetes Components

 

INFRASTRUCTURE OVERVIEW

  • We have already installed and configured the 2 Node cluster in our demo environment.

 

INSTALLING DASHBOARD

  • Log in to the kubernetes master server through putty.

Steps to Install Kubernetes Dashboard

 

  • The kubernetes dashboard will not be installed by default. Use the below command to install the dashboard.

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

Steps to Install Kubernetes Dashboard

 

  • It will take few seconds to complete the installation.

Steps to Install Kubernetes Dashboard

 

CONFIGURING DASHBOARD

  • By default, the dashboard will install with minimum user role privileges.
  • To access the dashboard with full administrative permission, create a YAML file named dashboard-admin.yaml.

vi dashboard-admin.yaml

Steps to Install Kubernetes Dashboard

  • Add the below coding in the YAML file and save it.

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

Steps to Install Kubernetes Dashboard

 

  • Apply the full admin privileges to dashboard service account using the dashboard-admin YAML file.

kubectl create -f dashboard-admin.yaml

Steps to Install Kubernetes Dashboard

 

  • It will take few seconds to apply the settings.

Steps to Install Kubernetes Dashboard

 

ENABLING THE PROXY

  • From the master server, execute the below command to run the kubernetes proxy command in the background.

nohup kubectl proxy --address="192.168.3.81" -p 443 --accept-hosts='^*$' &

Steps to Install Kubernetes Dashboard

 

Note: We have specified the master kubernetes server IP address in the address option. It may vary based on your environment.

 

  • The proxy address has been added successfully.

Steps to Install Kubernetes Dashboard

 

  • You can verify process status using the below command.

Steps to Install Kubernetes Dashboard

 

  • You can delete the process using the kill command.

kill -9 <process ID>

Example: kill -9 6114

Steps to Install Kubernetes Dashboard

 

ACCESSING THE DASHBOARD

  • Open the web browser from your local PC and access the below URL.

http://192.168.3.81:443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

Steps to Install Kubernetes Dashboard

 

  • We can able to access the dashboard through the kubeconfig file or bearer token. We have already provided full admin access to dashboard service account. So just click on SKIP option to access the dashboard.

Steps to Install Kubernetes Dashboard

 

  • Now we will able to view the homepage of the kubernetes dashboard.

Steps to Install Kubernetes Dashboard

 

EXTERNAL LINKS

https://stackoverflow.com/questions/46664104/how-to-sign-in-kubernetes-dashboard

https://stackoverflow.com/questions/36270602/how-to-access-kubernetes-ui-via-browser

https://github.com/kubernetes/dashboard/wiki/Access-control#basic

https://kubernetes.io/docs/admin/authentication/

https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/

 

VIDEO

Thanks for reading this blog. we hope it was useful for you to learn about installing dashboard on the kubernetes environment.



Author: Loges
Logeswaran holds Microsoft certified engineer & solution architect certifications with over 11+ years of experience in the fields of hosting technologies and IMS/Cloud consulting. At AssistanZ, Logeswaran spearheads the strategic planning and execution of the company’s Microsoft based core technologies to Enterprise clients.

29 Comments

  • Marcelo

    Greate article Loges. Thanks for sharing your knowledge. There is a way to start dashboard without need to run the nohup command? Maybe a shell script auto start from VM?

  • Hi Marcelo,

    Thanks for your comment. I think we can add a script in bashsrc to start the kubernetes dashboard during VM startup.

    Regards,
    Loges

  • Andy

    Hello,

    Great instructions on how to setup a kubernetes cluster! I am having some issue installing the dashboard. Please see output below and advise.
    [root@sj-k8s-master01 ~]# kubectl create -f dashboard-admin.yaml
    error: error converting YAML to JSON: yaml: line 12: mapping values are not allowed in this context

  • Hi Andy,

    Thanks for your comment.

    It’s looks like there is a problem with your YAML file. Make sure that tabs (or) any extra spaces has been added in your file.

    Regards,
    Loges

  • asatsi

    Nice quick hack!

  • Bhageerath

    Hi,

    Thanks a lot for the details steps. Much appreciated. Saved me lot of time.

  • Thanks for your comment Bhageerath 🙂

  • Kiran Kumar CH

    Thanks Loges for sharing 😀 😀

  • Harish

    Hi i was stuck at nohup
    nohup: ignoring input and appending output to ‘nohup.out’\
    please Help me

  • Apoorva

    Hello,

    I am unable to access my dashboard with the URL. This is the error: “message”: “services \”https:kubernetes-dashboard:\” is forbidden: User \”system:anonymous\” cannot get services/proxy in the namespace \”kube-system\””,
    “reason”: “Forbidden”,
    “details”: {
    “name”: “https:kubernetes-dashboard:”,
    “kind”: “services”
    },
    “code”: 403
    }

  • Hello,

    while I want to access my dashboard, I am getting this error:
    “message”: “services \”https:kubernetes-dashboard:\” is forbidden: User \”system:anonymous\” cannot get services/proxy in the namespace \”kube-system\””,
    “reason”: “Forbidden”,
    “details”: {
    “name”: “https:kubernetes-dashboard:”,
    “kind”: “services”
    },
    “code”: 403
    }

  • Anonymous

    “message”: “services \”https:kubernetes-dashboard:\” is forbidden: User \”system:anonymous\” cannot get services/proxy in the namespace \”kube-system\””,
    “reason”: “Forbidden”,
    “details”: {
    “name”: “https:kubernetes-dashboard:”,
    “kind”: “services”
    },
    “code”: 403
    }

  • Fernando

    Hello Loges great article, but I have a problem, when I execute proxy command nothing happens, the image shows that it jumps to another line (allowing you to type in the console), but in my case it does not, as if it were waiting, I check the pods and the pod of the dashboard never changes its status of “ContainerCreating” “I made a description of the pod and in the last event I have this:

     Failed create sandbox: rpc error: code = DeadlineExceeded desc = context deadline exceeded

    I’ve been looking for the solution for some time but I still can not find it, some idea of ​​how to solve it?

  • Golan

    I got the same problem as Andy.
    There was a space missing in the text
    – kind: ServiceAccount
    should have another space between – and k
    – kind: ServiceAccoun

  • babuni

    Hello,

    Great instructions on how to setup a kubernetes cluster! I am having some issue installing the dashboard. Please see output below and advise.
    [root@sj-k8s-master01 ~]# kubectl create -f dashboard-admin.yaml
    error: error converting YAML to JSON: yaml: line 12: mapping values are not allowed in this context

    ****************
    Answer:
    Only give a space on line number 12.

  • shubham

    I have problem in dashboard ui. It gives me “Unauthorized” . I followed this article to install dashborad. Help me out from this…thanks

  • shubham

    I have problem to open dashboard from host machine it gives me unauthorized/h3

  • shubham

    I have issue to see dashboard it gives me unauthorised/h3. Plz help me out from this.

  • shubham

    I got this message in my browser

    {
    “kind”: “Status”,
    “apiVersion”: “v1”,
    “metadata”: {

    },
    “status”: “Failure”,
    “message”: “no endpoints available for service \”kubernetes-dashboard\””,
    “reason”: “ServiceUnavailable”,
    “code”: 503
    }

  • Samkrish

    I just followed your document but I am getting “Error while initializing connection to Kubernetes apiserver. This most likely means that the cluster is misconfigured (e.g., it has invalid apiserver certificates or service account’s configuration) or the –apiserver-host param points to a server that does not exist. Reason: Get https://XXXXXXX:443/version: dial tcp XXXXXXXXX:443: i/o timeout”
    Thanks in advance

  • Nisar

    Awesome, Thank you. This was very easy to follow!

  • Giuseppe

    I also had the same mistake of Andy:
    error: error parsing dashboard-admin.yaml: error converting YAML to JSON: yaml: line 12: mapping values are not allowed in this context
    Can i resolve it?

  • ganeshbabu

    [root@kube-dashboard ~]# kubectl create -f kubernetes-dashboard.yaml
    The connection to the server localhost:8080 was refused – did you specify the right host or port?

  • Ankit Jain

    Hi Loges,
    I followed the steps above exactly as you’ve mentioned but I still am not able to access the Dashboard UI from my browser.
    I have noticed that I am not able to telnet 443 even though is in listen mode on port 443.
    Could you help?

  • Darshan

    Did everything as mentioned, only the last part is not working, not able to access the webui

    Getting the below error

    curl -kv http://172.31.26.70:443
    * About to connect() to 172.31.26.70 port 443 (#0)
    * Trying 172.31.26.70…
    * Connected to 172.31.26.70 (172.31.26.70) port 443 (#0)
    > GET / HTTP/1.1
    > User-Agent: curl/7.29.0
    > Host: 172.31.26.70:443
    > Accept: */*
    >
    < HTTP/1.1 502 Bad Gateway
    < Date: Sat, 06 Oct 2018 15:22:03 GMT
    < Content-Length: 0
    <
    * Connection #0 to host 172.31.26.70 left intact

  • Linh

    Hi Mr.Loges;
    I have setup these steps about install kubernetes dashboard in your post.
    But, It have issue is not access to kubernetes dashboard bellow.
    Could you please help me!
    {
    “kind”: “Status”,
    “apiVersion”: “v1”,
    “metadata”: {

    },
    “status”: “Failure”,
    “message”: “no endpoints available for service \”https:kubernetes-dashboard:\””,
    “reason”: “ServiceUnavailable”,
    “code”: 503
    }

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.