I have got the following services:
ubuntu@master:~$ kubectl get services --all-namespaces
NAMESPACE NAME CLUSTER-IP EXTERNAL-IP
The offical wiki is a little bit confusing so I reordered it here:
If you use the recommended yaml to deploy the dashboard, you should only access your dashboard by https, and you should generate your certs, refer to guide.
Then you can run kubectl proxy --address='0.0.0.0' --accept-hosts='^*$'
to visit the dashboard on "http://localhost:8001/ui". This page needs to use a token to login. To generate it, refer to this page. Also you can add NodePort
to your yaml and access it using <nodeip>:<port>
.
If you deploy using the http alternative method, you can only access your dashboard by nodeip:port. Remember to add it to yaml first!!
After deployment, you should also generate your token and add header Authorization: Bearer <token>
for every request.
I think this can help you and others who want to use kube-dashboard.
Just add a little clarity to the above response,
Change type: ClusterIP to type: NodePort and save file.
Dashboard has been exposed on port 31707 (HTTPS). Now you can access it from your browser at: https://master-ip:31707.
Note: The port mentioned could be difference in your case, just run the below kubectl command to get the port from master.
kubectl -n kube-system get service kubernetes-dashboard
You can reach by hitting the nodePort for the dashboard on the master
kubectl describe services kubernetes-dashboard --namespace=kube-system
NodePort: <unset> 30042/TCP
http://MASTER:30042
You can reference the document:
https://github.com/kubernetes/dashboard/wiki/Accessing-Dashboard---1.7.X-and-above
The easy way is to
$ kubectl -n kube-system edit service kubernetes-dashboard
change the .spec.type
to NodePort
Using terminal app on my laptop did the following:
sudo ssh -i “MYAMOZONHOSTKEYPAIR.pem" -L 8001:127.0.0.1:8001 ubuntu@MYAMAZONHOST
MYAMAZONHOST is where I am running k3s.
Upon SSH did the following:
sudo k3s kubectl proxy
Then using the browser opened the url http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
Kubernetes dashboard opened successfully.
You need to run kubectl proxy locally for accessing the dashboard outside the kubernetes cluster. This is because of the authentication mechanism. After running the below command you'll be able to view the dashboard at http://localhost/ui on your browser. The admin.conf file is the file on your kubernetes master at /etc/kubernetes/admin.conf You'll have to scp that file to the machine from which you want to access the dashboard and pass it to kubectl command.
kubectl --kubeconfig=./admin.conf proxy -p 80
The nodePort approach as mentioned by @user2363318 will be applicable if one of the following two conditions is valid: