windowskuberneteshyper-vmicrok8smultipass

Microk8s Access nginx pod to other Host Machines


I am using MIcrok8s 1.26v using Hyperv over windows 10. I am unable to access nginx pod to other host machines. I have exposed nginx using this cmd “microk8s kubectl expose deployment nginx-webserver --type=“NodePort” --port 80”. Its exposed to the clusterIP which i am able to access. What should i do to make the pod access to other host machines on the same network.

Microk8s version: 1.26v windows version: 10 Pro Hypervisor: HyperV Using Multipass

I tried to access the pod with vm IP address. But was not able to access to other host machine. Also not accessible to the host ip address where vm is deployed.


Solution

  • I got the solution after lots of research. Step1: Because the IP address keeps on changing I have take this step. To make microk8s work on DNS instead of IP Address

    Edit the config file after login into microk8s-vm shell using multipass shell micrk8s-vm in cmd. Login to root user. sudo su vi /var/snap/microk8s/current/certs/csr.conf.template

    add line >>>>>> under alt.names>>>>DNS.6 = microk8s-vm.mshome.net exit the vim editor

    Update the .kube/config and Microk8s/config . Replace the IP Address with the given dns name(eg: microk8s-vm.mshome.net)

    Microk8s stop Restart the Host machine.

    Step 2: Because Microk8s port forwarding fails i have to opt for windows port forwarding. Configure Windows port forwarding :https://woshub.com/port-forwarding-in-windows/

    Now i am able to access the nginx web server on other windows machine.