首页 > 解决方案 > 无法通过主机的特定 http 端口访问多通道 VM

问题描述

我正在运行带有 multipass hyperkit 的 Ubuntu VM,确实运行 microk8s。在 VM 中,所有东西都可以通过 skaffold/kubectl 端口转发进行结帐。例如:

$ multipass list
Name                    State             IPv4             Image
microk8s-vm             Running           192.168.64.2     Ubuntu 20.04 LTS
                                          10.0.1.1
                                          172.17.0.1
                                          10.1.254.64

Port forwarding service/my-app in namespace default, remote port 80 -> 127.0.0.1:4503

在虚拟机内:curl localhost:4503✅</p>

来自主持人:curl 192.168.64.2:4503

我知道 VM 可以在端口 80 上访问,因为curl 192.168.64.2返回默认的 ngnix 未找到页面。FWIW 我从未安装过 ngnix 并且该服务似乎没有运行/无法将其关闭。

我已经在这里待了一天,我很困惑。我什至尝试了 Vbox 驱动程序并手动配置了一个桥接适配器。我什至创建了自己的适配器...

$ multipass exec -- microk8s-vm sudo bash -c "cat > /etc/netplan/60-bridge.yaml" <<EOF
network:
  ethernets:
    enp0s8:                  # this is the interface name from above
      dhcp4: true
      dhcp4-overrides:       # this is needed so the default gateway
        route-metric: 200    # remains with the first interface
  version: 2
EOF
$ multipass exec microk8s-vm sudo netplan apply

如何从主机访问此 VM?

标签: macoskubernetesmicrok8sskaffoldmultipass

解决方案


推荐阅读