<p>I am learning Kubernetes, and I did create a LAB on a Bare-Metal, So I'm a Kubernetes noob!</p>
<p>I did create my <code>deployment</code> and it is running and accessible using <code>NodePort</code>, But when I use <code>nginx-ingress</code>, The nginx container is running and it is responding inside its container using <code>curl localhost</code>, but when I try from the outer world, I see this message: <code>curl: (7) Failed to connect to app.example.com port 80: Connection refused</code></p>
<p>These are my <code>app-service.yml</code> and <code>app-ingress.yml</code> which they are running.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: my-app-service
spec:
  ports:
  - port: 80
    targetPort: 3010
    protocol: TCP
    name: http
  selector:
    app: my-app
</code></pre>
<pre class="lang-yaml prettyprint-override"><code>kind: Ingress
metadata:
  name: my-ingress
  labels:
    app: my-app
  annotations:
    # use the shared ingress-nginx
    kubernetes.io/ingress.class: &quot;nginx&quot;
spec:
  rules:
  - host: app.example.com
    http:
      paths:
      - path: /
        backend:
          serviceName: my-app-service
          servicePort: 80
</code></pre>
<p>Also my deployment:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app-deployment
  labels:
    app: my-app
spec:
  replicas: 2
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: my-app
          image: my-app:1.0
          ports:
            - containerPort: 3010
</code></pre>
<p>The command: <code>kubectl get all --namespace ingress-nginx</code> is showing:</p>
<pre><code>NAME                                            READY   STATUS      RESTARTS   AGE
pod/ingress-nginx-admission-create-tc8t7        0/1     Completed   0          73m
pod/ingress-nginx-admission-patch-lnbcp         0/1     Completed   2          73m
pod/ingress-nginx-controller-7fd7d8df56-bjmrm   1/1     Running     0          74m

NAME                                         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
service/ingress-nginx-controller             NodePort    10.110.64.201    &lt;none&gt;        80:30532/TCP,443:31993/TCP   74m
service/ingress-nginx-controller-admission   ClusterIP   10.108.186.241   &lt;none&gt;        443/TCP                      74m

NAME                                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/ingress-nginx-controller   1/1     1            1           74m

NAME                                                  DESIRED   CURRENT   READY   AGE
replicaset.apps/ingress-nginx-controller-7fd7d8df56   1         1         1       74m

NAME                                       COMPLETIONS   DURATION   AGE
job.batch/ingress-nginx-admission-create   1/1           5s         74m
job.batch/ingress-nginx-admission-patch    1/1           19s        74m
</code></pre>
<p>and the command: <code>kubectl get ing</code> is showing:</p>
<pre class="lang-sh prettyprint-override"><code>NAME          CLASS    HOSTS                  ADDRESS         PORTS   AGE
my-ingress   &lt;none&gt;   app.example.com         X.X.X.X         80      11m
</code></pre>

Vahid Alimohamadi
<p><code>ClusterIP</code> is not accessible from outside kubernetes cluster. <code>ClusterIP</code> provides L4 layer loadbalancing.</p>
<p>From the docs <a href="https://kubernetes.github.io/ingress-nginx/deploy/baremetal/" rel="nofollow noreferrer">here</a> you few options for nginx ingress on bare metal</p>
<ol>
<li>Use MetalLB as pure software loadbalancer implementation</li>
<li>Use <code>NodePort</code> service to expose nginx ingress controller. Note you are not using <code>NodePort</code> to expose the regular pod.You are getting benefit of L7 layer load balancing by nginx.</li>
<li>Run nginx with <code>hostNetwork:true</code></li>
</ol>
<p>If you choose option 3 which is easiest in my opinion you can access the kubernetes pod via ingress using <code>curl http://&lt;NODEIP&gt; -H &quot;Host: app.example.com&quot;</code></p>
