简体   繁体   English

访问 minikube 仪表板 - (Ubuntu20.04 服务器)运行在 Windows 10 主机上的 VirtualBox 6.1 虚拟机

[英]Accessing minikube dashboard - (Ubuntu20.04 server)VM running on Windows 10 host with VirtualBox 6.1

I'm trying to access minikube dashboard from host OS (Windows 10).我正在尝试从主机操作系统 (Windows 10) 访问 minikube 仪表板。

Minikube is running on my virtual machine Ubuntu 20.04 server. Minikube 在我的虚拟机 Ubuntu 20.04 服务器上运行。

The host is Windows 10 and I use VirtualBox to run my VM.主机是 Windows 10,我使用 VirtualBox 来运行我的 VM。

These are the commands I ran on Ubuntu:这些是我在 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:然后我打开另一个终端 window 并运行:

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:现在在我的 Windows 10 主机上,我 go 到 web 浏览器输入:

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?如何从我的主机操作系统 web 浏览器访问 minikube 仪表板?

Reproduction再生产

I reproduced this behaviour on Windows 10 and ubuntu 18.04 LTS virtual machine running using VirtualBox .我在使用VirtualBox运行的 Windows 10 和 ubuntu 18.04 LTS 虚拟机上重现了此行为。

I have tried both minikube drivers : docker and none (last one means that all kube.netes components will be run on localhost) and behaviour is the same.我已经尝试了两个minikube drivers :docker 和一个都没有(最后一个意味着所有 kube.netes 组件都将在本地主机上运行)并且行为是相同的。

What happens会发生什么

Minikube is designed to be used on localhost machine. Minikube 被设计为在本地主机上使用。 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 .当运行minikube dashboard命令时,minikube 下载图像(指标抓取器和仪表板本身),启动它们,测试它们是否健康,然后创建在localhost上运行的代理。 It can't accept connections outside of the virtual machine (in this case it's Windows host to ubuntu VM).它不能接受虚拟机外部的连接(在这种情况下,它是 Windows 主机到 ubuntu VM)。

This can be checked by running netstat command (cut off some not useful output):这可以通过运行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

How to resolve it如何解决

Once minikube dashboard command has been run, kube.netes dashboard will remain running in kube.netes-dashboard namespace.运行minikube dashboard命令后,kube.netes dashboard 将继续在kube.netes-dashboard命名空间中运行。

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:或者如果你的机器上没有安装kubectl

minikube kubectl proxy -- --address='0.0.0.0' &

It will start a proxy to kube.netes 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 ).它将在端口8001上启动一个到 kube.netes api 服务器的代理,并将服务于所有地址(它可以更改为默认虚拟框 NAT 地址10.2.0.15 )。

Next step is to add port-forwarding in VirtualBox.下一步是在 VirtualBox 中添加port-forwarding Go to your virtual machine -> settings ->.network -> NAT -> advanced -> port-forwarding Go 到您的虚拟机 -> 设置 ->.网络 -> NAT -> 高级 -> 端口转发

Add a new rule:添加新规则:

  • host IP = 127.0.0.1主机 IP = 127.0.0.1
  • host port = any free one, eg I used 8000 host port = 任何空闲端口,例如我使用 8000
  • guest IP = can be left empty客人 IP = 可以留空
  • guest port = 8001 (where proxy is listening to)来宾端口 = 8001(代理正在侦听)

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:现在您可以将 go 发送到 Windows 主机上的浏览器,粘贴 URL,更正在host port中分配的端口,它将起作用:

http://127.0.0.1:8000/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

Useful links:有用的链接:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 连接到 ubuntu 上运行的 kafka 集群 20.04 在 Windows 主机上的 VirtualBox 中运行 - Connect to kafka cluster running on ubuntu 20.04 running in VirtualBox on Windows host 为什么virtualbox无法在Ubuntu20.04上安装 - Why virtualbox fails to install on Ubuntu20.04 minikube 启动错误 virtualbox 6.1 ubuntu - minikube start error virtualbox 6.1 ubuntu minikube 中的 minikube 错误在 Oracle VirtualBox 中安装了 Ubuntu16.04 VM - minikube error in minikube installed Ubuntu16.04 VM in Oracle VirtualBox Ubuntu20.04上的Nvidia驱动 - Nvidia Driver on Ubuntu20.04 无法安装Symfony3。 Virtualbox-Ubuntu来宾/ Windows 10主机 - Trouble installing Symfony3. Virtualbox - Ubuntu guest / Windows 10 host 在 WSL2(Ubuntu 20.04)中运行的 Nginx 不为 HTML 页面提供 Windows 10 主机上的另一个端口而不是端口 80 - Nginx running in WSL2 (Ubuntu 20.04) does not serve HTML page to Windows 10 host on another port than port 80 无法通过仅主机网络连接到在Virtualbox ubuntu VM上运行的mysql数据库 - Unable to connect to mysql database running on a Virtualbox ubuntu VM with host-only network 在 Ubuntu20.04 中构建 Gem5 - builing Gem5 in Ubuntu20.04 在 VirtualBox 上运行 Ubuntu 20.04 时找不到重命名命令 - rename command not found when running Ubuntu 20.04 on VirtualBox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM