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.
- Please check the URL https://www.assistanz.com/steps-to-install-kubernetes-cluster-manually-using-centos-7/ for more information.
INSTALLING DASHBOARD
- Log in to the kubernetes master server through putty.
- 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
- It will take few seconds to complete the installation.
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
- 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
- Apply the full admin privileges to dashboard service account using the dashboard-admin YAML file.
kubectl create -f dashboard-admin.yaml
- It will take few seconds to apply the settings.
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='^*$' &
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.
- You can verify process status using the below command.
- You can delete the process using the kill command.
kill -9 <process ID>
Example: kill -9 6114
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/
- 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.
- Now we will able to view the homepage of the 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.
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
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
Nice quick hack!
Hi,
Thanks a lot for the details steps. Much appreciated. Saved me lot of time.
Thanks for your comment Bhageerath 🙂
Thanks Asatsi 🙂
Thanks Loges for sharing 😀 😀
Hi i was stuck at nohup
nohup: ignoring input and appending output to ‘nohup.out’\
please Help me
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
}
“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
}
hi
TEST
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?
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
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.
I have problem in dashboard ui. It gives me “Unauthorized” . I followed this article to install dashborad. Help me out from this…thanks
I have problem to open dashboard from host machine it gives me unauthorized/h3
I have issue to see dashboard it gives me unauthorised/h3. Plz help me out from this.
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
}
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
Awesome, Thank you. This was very easy to follow!
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?
[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?
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?
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
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
}
kubectl create -f dashboard-admin.yaml
The connection to the server 192.168.91.128:6443 was refused – did you specify the right host or port?
How do I resolve this? pls help..!!
Hello, does anybody get error:
Error: ‘dial tcp 10.244.1.181:8443: i/o timeout’
Trying to reach: ‘https://10.244.1.181:8443/’ ?
oot@master ~]# kubectl create -f dashboard-admin.yaml
Error from server (AlreadyExists): error when creating “dashboard-admin.yaml”: clusterrolebindings.rbac.authorization.k8s.io “kubernetes-dashboard” already exists