How to expose Microk8s containers, so they are available from another machine? How to expose Microk8s containers, so they are available from another machine? kubernetes kubernetes

How to expose Microk8s containers, so they are available from another machine?


You are right, if you want to connect to your cluster from outside, you have to expose service as LoadBalancer or NodePort.

Unfortunately, as you are not using any cloud provider which support LoadBalancer (like AWS or GCP which provides External-IPs) you will be not able to expose service as LoadBalancer (service stuck on Pending state). As describe here:

LoadBalancer: Exposes the Service externally using a cloud provider’sload balancer. NodePort and ClusterIP Services, to which the externalload balancer routes, are automatically created.

As default in Microk8s you can use only services like NodePort and ClusterIP.

With your setup you can use NodePort, ClusterIP with Ingress or MetalLB. If you will use Ingress you have to remember to enable ingress and dns addons in Microk8s. It can be done by $ microk8s.enable dns ingress.

In short. Options you have are:

  1. Use NodePort
  2. Use Ingress Controller
  3. Set Endpoints in your YAMLs or use MetalLB and point Endpoints.

In Addition you can check similar case here and here.

Hope it helps.