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:
- Use
NodePort
- Use Ingress Controller
- Set
Endpoints
in your YAMLs or use MetalLB and point Endpoints.
In Addition you can check similar case here and here.
Hope it helps.