[英]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 仪表板?
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 组件都将在本地主机上运行)并且行为是相同的。
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
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:添加新规则:
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/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.