Reputation: 963
I'm trying to access minikube dashboard from host OS (Windows 10).
Minikube is running on my virtual machine Ubuntu 20.04 server.
The host is Windows 10 and I use VirtualBox to run my VM.
These are the commands I ran on Ubuntu:
tomas@ubuntu20:~$ minikube start
* minikube v1.22.0 on Ubuntu 20.04 (vbox/amd64)
* Using the docker driver based on existing profile
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Updating the running docker "minikube" container ...
* Preparing Kubernetes v1.21.2 on Docker 20.10.7 ...
* Verifying Kubernetes components...
- Using image gcr.io/k8s-minikube/storage-provisioner:v5
- Using image kubernetesui/dashboard:v2.1.0
- Using image kubernetesui/metrics-scraper:v1.0.4
* Enabled addons: storage-provisioner, default-storageclass, dashboard
* kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
tomas@ubuntu20:~$ kubectl get po -A
Command 'kubectl' not found, but can be installed with:
sudo snap install kubectl
tomas@ubuntu20:~$ minikube kubectl -- get po -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-558bd4d5db-9p9ck 1/1 Running 2 72m
kube-system etcd-minikube 1/1 Running 2 72m
kube-system kube-apiserver-minikube 1/1 Running 2 72m
kube-system kube-controller-manager-minikube 1/1 Running 2 72m
kube-system kube-proxy-xw766 1/1 Running 2 72m
kube-system kube-scheduler-minikube 1/1 Running 2 72m
kube-system storage-provisioner 1/1 Running 4 72m
kubernetes-dashboard dashboard-metrics-scraper-7976b667d4-r9k7t 1/1 Running 2 54m
kubernetes-dashboard kubernetes-dashboard-6fcdf4f6d-c7kwf 1/1 Running 2 54m
And then I open another terminal window and I run:
tomas@ubuntu20:~$ minikube dashboard
* Verifying dashboard health ...
* Launching proxy ...
* Verifying proxy health ...
* Opening http://127.0.0.1:36337/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...
http://127.0.0.1:36337/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
Now on my Windows 10 host machine I go to web browser type in:
http://127.0.0.1:36337/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
But I get error:
This site canβt be reached 127.0.0.1 refused to connect.
How can I access minikube dashboard from my host OS web browser?
Upvotes: 3
Views: 3493
Reputation: 4181
I reproduced this behaviour on Windows 10 and ubuntu 18.04 LTS virtual machine running using VirtualBox
.
I have tried both minikube drivers
: docker and none (last one means that all kubernetes components will be run on localhost) and behaviour is the same.
Minikube is designed to be used on localhost machine. When minikube dashboard
command is run, minikube downloads images (metrics scraper and dashboard itsefl), launches them, test if they are healthy and then create proxy which is run on localhost
. It can't accept connections outside of the virtual machine (in this case it's Windows host to ubuntu VM).
This can be checked by running netstat
command (cut off some not useful output):
$ minikube dashboard
π Enabling dashboard ...
π Launching proxy ...
π€ Verifying proxy health ...
π http://127.0.0.1:36317/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
$ sudo netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:36317 0.0.0.0:* LISTEN 461195/kubectl
Once minikube dashboard
command has been run, kubernetes dashboard will remain running in kubernetes-dashboard
namespace.
Proxy to it should be open manually with following command:
kubectl proxy --address='0.0.0.0' &
Or if you don't have kubectl
installed on your machine:
minikube kubectl proxy -- --address='0.0.0.0' &
It will start a proxy to kubernetes api server on port 8001
and will serve on all addresses (it can be changed to default Virtual box NAT address 10.2.0.15
).
Next step is to add port-forwarding
in VirtualBox.
Go to your virtual machine -> settings -> network -> NAT -> advanced -> port-forwarding
Add a new rule:
Now you can go to your browser on Windows host, paste the URL, correct the port which was assigned in host port
and it will work:
http://127.0.0.1:8000/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
Upvotes: 2