a11hard
a11hard

Reputation: 2054

Multipass VM not reachable via specific http ports from host

I'm running an Ubuntu VM with multipass hyperkit do run microk8s. Within the VM all things checkout and available with skaffold/kubectl port forwarding. For instance:

$ 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

Within the VM:curl localhost:4503 ✅

From the host: curl 192.168.64.2:4503🛑

I know the VM is reachable on port 80 because curl 192.168.64.2 returns default ngnix not found page. FWIW I never installed ngnix and the service doesn't seem to be running /cannot turn it off.

I've been at this for a day and I'm stumped. I even tried the Vbox driver and manually configured a bridge adapter. I even created my own adapter...

$ 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

How can I reach this VM from the host?

Upvotes: 14

Views: 3596

Answers (1)

Ralle Mc Black
Ralle Mc Black

Reputation: 1203

You cant access your pod ip /portlike this. If you want to access your pods port over the nodes ip address, you need to define a service type NodePort and then use ipaddressOfNode:NodePort.

curl http://ipaddressOfNode:NodePort

With port-forward you must use the localhost of your host system.

kubectl port-forward svc/myservice 8000:yourServicePort

then

curl http://localhost:8000

Upvotes: 0

Related Questions