我正在尝试从主机操作系统(Windows 10)上访问minikube仪表板。
Minikube正在我的虚拟机Ubuntu20.04服务器上运行。
主机是Windows 10,我使用VirtualBox运行VM。
下面是我在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然后我打开另一个终端窗口,然后运行:
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/现在,在我的Windows 10主机上,我进入web浏览器输入:
http://127.0.0.1:36337/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/但我错了:
This site can’t be reached 127.0.0.1 refused to connect.我怎样才能从我的主机操作系统网页浏览器上访问minikube仪表板?
发布于 2021-08-19 09:44:34
再生产
我在使用VirtualBox运行的Windows 10和ubuntu18.04LTS虚拟机上复制了这种行为。
我已经尝试过minikube drivers:docker和none (最后一个意味着所有kubernetes组件都将在本地主机上运行),并且行为是相同的。
会发生什么?
Minikube被设计用于本地主机上。运行minikube dashboard命令时,minikube下载图像(指标刮板和仪表板itsefl),启动它们,测试它们是否正常,然后创建运行在localhost上的代理。它不能接受虚拟机之外的连接(在本例中,它是到ubuntu的Windows主机)。
可以通过运行netstat命令(切断一些无用的输出)来检查这一点:
$ 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如何解决这个问题
一旦运行了minikube dashboard命令,kubernetes仪表板将继续在kubernetes-dashboard命名空间中运行。
它的代理应该使用以下命令手动打开:
kubectl proxy --address='0.0.0.0' &或者如果您的计算机上没有安装kubectl:
minikube kubectl proxy -- --address='0.0.0.0' &它将在端口8001上启动kubernetes api服务器的代理,并在所有地址上提供服务(它可以更改为默认的Virtual地址10.2.0.15)。
下一步是在VirtualBox中添加port-forwarding。转到虚拟机->设置->网络NAT ->高级->端口转发
增加一条新规则:
现在,您可以转到Windows主机上的浏览器,粘贴URL,更正host port中分配的端口,这样就可以工作了:
http://127.0.0.1:8000/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/有用的链接:
https://stackoverflow.com/questions/68833218
复制相似问题