<p>I'd like to use <a href="https://microk8s.io/" rel="noreferrer">Microk8s</a> for playing around Spring Cloud Data Flow, so I installed Multipass on my Windows 10, and in a virtual machine I run an Ubuntu where Microk8s is installed. I'd like to achieve that, all containers run on Ubuntu, which is a headless Virtualbox VM managed by Multipass, but I'd like to be able to connect to the containers from Windows.</p>

<p>The topology looks like this:</p>

<p><strong>Windows 10</strong>:</p>

<ul>
<li>192.168.1.107 provided by my home router</li>
</ul>

<p><strong>Ubuntu</strong> which runs in Virtualbox</p>

<ul>
<li>192.168.52.1 provided by, I believe, Windows for Virtualbox (Virtualbox Host-Only Network)</li>
</ul>

<p>If I log in Ubuntu <code>ifconfig</code> says the following:</p>

<pre><code>multipass@scdf:~/scdf/spring-cloud-dataflow$ ifconfig                                                                                                                               
cbr0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500                                                                                                                                  
        inet 10.1.1.1  netmask 255.255.255.0  broadcast 0.0.0.0                                                                                                                             
        inet6 fe80::c802:9fff:fea2:93f1  prefixlen 64  scopeid 0x20&lt;link&gt;                                                                                                                   
        ether ca:02:9f:a2:93:f1  txqueuelen 1000  (Ethernet)                                                                                                                                
        RX packets 19890  bytes 6628126 (6.6 MB)                                                                                                                                            
        RX errors 0  dropped 0  overruns 0  frame 0                                                                                                                                         
        TX packets 21413  bytes 13988665 (13.9 MB)  

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0                                                                                                                  
enp0s3: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::a00:27ff:feba:30bb  prefixlen 64  scopeid 0x20&lt;link&gt;
        ether 08:00:27:ba:30:bb  txqueuelen 1000  (Ethernet)
        RX packets 208972  bytes 273941063 (273.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 24249  bytes 2084939 (2.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73&lt;UP,LOOPBACK,RUNNING&gt;  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10&lt;host&gt;
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 157483  bytes 40950239 (40.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 157483  bytes 40950239 (40.9 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
</code></pre>

<p><code>microk8s.kubectl get all</code> says the following, it's been executed in Ubuntu:</p>

<pre><code>multipass@scdf:~/scdf/spring-cloud-dataflow$ microk8s.kubectl get all
NAME                                          READY   STATUS    RESTARTS   AGE
pod/default-http-backend-5d5ff5d4f5-6ttvd     1/1     Running   1          29m
pod/kafka-broker-64445d8596-88rl6             1/1     Running   24         98m
pod/kafka-zk-77bdb5bcbb-qjxfh                 1/1     Running   4          98m
pod/mysql-bdd598966-nknwk                     0/1     Pending   0          87m
pod/nginx-ingress-microk8s-controller-dh28n   1/1     Running   1          29m


NAME                           TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
service/default-http-backend   ClusterIP      10.152.183.57    &lt;none&gt;        80/TCP                       29m
service/kafka                  ClusterIP      10.152.183.194   &lt;none&gt;        9092/TCP                     98m
service/kafka-zk               ClusterIP      10.152.183.80    &lt;none&gt;        2181/TCP,2888/TCP,3888/TCP   98m
service/kubernetes             ClusterIP      10.152.183.1     &lt;none&gt;        443/TCP                      100m
service/mysql                  ClusterIP      10.152.183.113   &lt;none&gt;        3306/TCP                     87m
service/scdf-server            LoadBalancer   10.152.183.122   &lt;pending&gt;     80:32548/TCP                 80m
service/skipper                LoadBalancer   10.152.183.163   &lt;pending&gt;     80:30955/TCP                 81m

NAME                                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
daemonset.apps/nginx-ingress-microk8s-controller   1         1         1       1            1           &lt;none&gt;          29m

NAME                                   READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/default-http-backend   1/1     1            1           29m
deployment.apps/kafka-broker           1/1     1            1           98m
deployment.apps/kafka-zk               1/1     1            1           98m
deployment.apps/mysql                  0/1     1            0           87m
deployment.apps/scdf-server            0/1     0            0           80m
deployment.apps/skipper                0/1     0            0           82m

NAME                                              DESIRED   CURRENT   READY   AGE
replicaset.apps/default-http-backend-5d5ff5d4f5   1         1         1       29m
replicaset.apps/kafka-broker-64445d8596           1         1         1       98m
replicaset.apps/kafka-zk-77bdb5bcbb               1         1         1       98m
replicaset.apps/mysql-bdd598966                   1         1         0       87m
replicaset.apps/scdf-server-6988d7795f            1         0         0       80m
replicaset.apps/skipper-5957946bf5                1         0         0       82m
</code></pre>

<p>As you can see there are two <code>&lt;Pending&gt;</code> status for external IP addresses. I believe those should be exposed in order to be able to connect to.</p>

<p>I did what I found in <a href="https://kubernetes.io/docs/tutorials/stateless-application/expose-external-ip-address/" rel="noreferrer">this</a> help, but I couldn't reach that the server gets external IP.</p>

<p>What I'm doing here wrong?
Is Microk8s able to expose its containers?</p>

<p>You are right, if you want to connect to your cluster from outside, you have to expose service as <code>LoadBalancer</code> or <code>NodePort</code>.</p>
<p>Unfortunately, as you are not using any cloud provider which support <code>LoadBalancer</code> (like AWS or GCP which provides External-IPs) you will be not able to expose service as <code>LoadBalancer</code> (service stuck on <code>Pending</code> state). As describe <a href="https://kubernetes.io/docs/concepts/services-networking/#publishing-services-service-types" rel="noreferrer">here</a>:</p>
<blockquote>
<p>LoadBalancer: Exposes the Service externally using a cloud provider’s
load balancer. NodePort and ClusterIP Services, to which the external
load balancer routes, are automatically created.</p>
</blockquote>
<p>As default in Microk8s you can use only services like <code>NodePort</code> and <code>ClusterIP</code>.</p>
<p>With your setup you can use <code>NodePort</code>, <code>ClusterIP</code> with <code>Ingress</code> or MetalLB. If you will use <code>Ingress</code> you have to remember to enable <code>ingress</code> and <code>dns</code> addons in <code>Microk8s</code>. It can be done by <code>$ microk8s.enable dns ingress</code>.</p>
<p>In short. Options you have are:</p>
<ol>
<li>Use <code>NodePort</code></li>
<li>Use <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-controllers" rel="noreferrer">Ingress Controller</a></li>
<li>Set <code>Endpoints</code> in your YAMLs or use <a href="https://metallb.universe.tf/configuration/" rel="noreferrer">MetalLB</a> and point Endpoints.</li>
</ol>
<p>In Addition you can check similar case <a href="https://stackoverflow.com/questions/44110876/kubernetes-service-external-ip-pending">here</a> and <a href="https://stackoverflow.com/questions/54506269/simple-ingress-from-host-with-microk8s">here</a>.</p>
<p>Hope it helps.</p>
