<p>I am currently setting up a kubernetes cluster (bare ubuntu servers). I deployed metallb and ingress-nginx to handle the ip and service routing. This seems to work fine. I get a response from nginx, when I wget the externalIP of the ingress-nginx-controller service (works on every node). But this only works inside the cluster network. How do I access my services (the ingress-nginx-controller, because it does the routing) from the internet through a node/master servers ip? I tried to set up routing with iptables, but it doesn't seem to work. What am I doing wrong and is it the best practise ?</p>
<pre><code>echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward

iptables -t nat -A PREROUTING -i eth0 -p tcp -d &lt;Servers IP&gt; --dport 80 -j DNAT --to &lt;ExternalIP of nginx&gt;:80

iptables -A FORWARD -p tcp -d &lt;ExternalIP of nginx&gt; --dport 80 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

iptables -F
</code></pre>
<p>Here are some more information:</p>
<pre><code>kubectl get services -n ingress-nginx

NAME                                 TYPE           CLUSTER-IP       EXTERNAL-IP    PORT(S)                      AGE
ingress-nginx-controller             LoadBalancer   10.103.219.111   198.51.100.1   80:31872/TCP,443:31897/TCP   41h
ingress-nginx-controller-admission   ClusterIP      10.108.194.136   &lt;none&gt;         443/TCP                      41h
</code></pre>
<p>Please share some thoughts
Jonas</p>

Jonaswinz
<p>Bare-metal cluster are a bit tricky to set-up because you need to create and manage the point of contact to your services. In cloud environment these are available on-demand.</p>
<p>I followed <a href="https://kubernetes.github.io/ingress-nginx/deploy/baremetal/" rel="nofollow noreferrer">this doc</a> and can assume that your load balancer seems to be working fine as you are able to <code>curl</code> this IP address. However, you are trying to get a response when calling a domain. For this you need some app running inside your cluster, which is exposed to hostname via Ingress component.</p>
<p>I'll take you through steps to achieve that.
First, create a Deployment to run a webservice, I'm gonna use simple nginx example:</p>
<pre><code>kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2 
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80 
</code></pre>
<p>Second, create a Service of type LoadBalancer to be able to access it externally. You can do that by simply running this command:
<code>kubectl expose deployment nginx-deployment --type=LoadBalancer --name=&lt;service_name&gt;</code>
If your software load balancer is set up correctly, this should give external IP address to the Deployment you created before.</p>
<p>Last but not least, create <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">Ingress</a> service which will manage external access and name-based virtual hosting. Example:</p>
<pre><code>kind: Ingress
metadata:
  name: &lt;ingress_name&gt;
spec:
  rules:
    - host: &lt;your_domain&gt;
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: &lt;service_name&gt;
                port:
                  number: 80
</code></pre>
<p>Now, you should be able to use your domain name as an external access to your cluster.</p>
