<p>I have built a K3s (<a href="https://k3s.io" rel="nofollow noreferrer">https://k3s.io</a>) cluster on a set of Raspberry Pi4 computers.</p>

<p>The controller (<code>ctrl-1</code>) node is a gateway in that it has 2 network interfaces. One is connected to my LAN and the other is connected to a network that it creates, e.g. K3S-LAN. The two nodes (<code>node-1</code> and <code>node-2</code>) are deployed to the K3S-LAN.</p>

<p>I want to be able to access the applications running on the nodes through <code>ctrl-1</code>, e.g. from the LAN. This is because this cluster is meant to be portable so only the <code>ctrl-1</code> node needs to be connected to the guest LAN. (Yes there are issues with DNS names etc to be sorted out, but I want to get the basics running first).</p>

<p>This means that I need to be able to "proxy" the ingress through <code>ctrl-1</code>. I thought I had the right idea for this in that I deployed "nginx-ingress" to the master, using Helm. However I forgot about the service for this - this has been scheduled on the nodes, whereas it needs to be on the controller so that the ports are opened up (I think). However I cannot find how to make the service run on the controller.</p>

<p>At the moment I have the service running with a type of <code>NodePort</code>. I could install MetalLB so that I have <code>LoadBalancer</code> capabilities. However with what I have seen I am not sure if this would help or not.</p>

<p><code>ctrl-1</code> does not have any taints setup on it, just the role of master.</p>

<p>Am I barking up the wrong tree here? I guess this might not be the intended use case of Kubernetes, but I am playing around with an idea. Thanks for any ideas that people have.</p>

<p><strong>Update*</strong></p>

<p>I have just thought that the way around this might be to run HAProxy on <code>ctrl-1</code> (as another service on the host) and setup rules to proxy to the necessary services within the cluster. That would act as the bridge between the networks.</p>

<ol>
<li><p>You just need to expose your pod via a Nodeport type service and it can be accessed via <a href="http://master-node-ip:nodeport" rel="nofollow noreferrer">http://master-node-ip:nodeport</a>. Make sure that kube-proxy is running on all master and worker nodes.</p></li>
<li><p>The ingress approach also should work as long as you have kube-proxy running on your master. You deploy nginx ingress on your cluster and it will get deployed into a worker node. Then you can expose nginx ingress controller itself using a NodePort service. After this you can create ingress resource for configuring the nginx ingress controller to route traffic to your backend pods and services running on worker nodes. The services for backend pods should be of type ClusterIP.</p></li>
</ol>

<p>Deploy nginx ingress controller and expose it via NodePort service using <code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.1/deploy/static/provider/baremetal/service-nodeport.yaml</code></p>

<p>Deploy nginx pod(nginx is an example..this should be your pod) <code>kubectl run nginx --generator=run-pod/v1 --image=nginx</code></p>

<p>Expose nginx pod via ClusterIP service</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  labels:
    run: nginx
  name: nginx-service
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    run: nginx
</code></pre>

<p>Create ingress resource</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata: 
  name: mycha-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - http:
      paths:
        - path: /
          backend:
            serviceName: nginx-service
            servicePort: 80
</code></pre>

<p>With above setup I can now access nginx and get "Welcome to nginx! " via <code>http://master-node-ip:NodePort of nginx ingress controller</code></p>
