<p>When setting up an ingress in my kubernetes project I can't seem to get it to work. I already checked following questions:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/65193758/enable-ingress-controller-on-docker-desktop-with-wls2">Enable Ingress controller on Docker Desktop with WLS2</a></li>
<li><a href="https://stackoverflow.com/questions/60839510/docker-desktop-k8s-plus-https-proxy-multiple-external-ports-to-pods-on-http-in">Docker Desktop + k8s plus https proxy multiple external ports to pods on http in deployment?</a></li>
<li><a href="https://stackoverflow.com/questions/59255445/how-can-i-access-nginx-ingress-on-my-local">How can I access nginx ingress on my local?</a></li>
</ul>
<p>But I can't get it to work. When testing the service via NodePort (<a href="http://kubernetes.docker.internal:30090/" rel="nofollow noreferrer">http://kubernetes.docker.internal:30090/</a> or localhost:30090) it works without any problem, but when using <a href="http://kubernetes.docker.internal/" rel="nofollow noreferrer">http://kubernetes.docker.internal/</a> I get kubernetes.docker.internal didn’t send any data. ERR_EMPTY_RESPONSE.</p>
<p>This is my yaml file:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: webapp
spec:
  minReadySeconds: 30
  selector:
    matchLabels:
      app: webapp
  replicas: 1
  template:
    metadata:
      labels:
        app: webapp
    spec:
      containers:
        - name: webapp
          image: gcr.io/google-samples/hello-app:2.0
          env:
            - name: &quot;PORT&quot;
              value: &quot;3000&quot;

---

apiVersion: v1
kind: Service
metadata:
  name: webapp-service

spec:
  selector:
    app: webapp

  ports:
    - name: http
      port: 3000
      nodePort: 30090 # only for NotPort &gt; 30,000

  type: NodePort #ClusterIP inside cluster

---

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: webapp-ingress
spec:
  defaultBackend:
    service:
      name: webapp-service
      port:
        number: 3000
  rules:
    - host: kubernetes.docker.internal
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name:  webapp-service
                port:
                  number: 3000
</code></pre>
<p>I also used following command:</p>
<pre><code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.45.0/deploy/static/provider/cloud/deploy.yaml
</code></pre>
<p>The output of  <code>kubectl get all -A</code> is as follows (indicating that the ingress controller is running):</p>
<pre><code>NAMESPACE       NAME                                            READY   STATUS      RESTARTS   AGE
default         pod/webapp-78d8b79b4f-7whzf                     1/1     Running     0          13m
ingress-nginx   pod/ingress-nginx-admission-create-gwhbq        0/1     Completed   0          11m
ingress-nginx   pod/ingress-nginx-admission-patch-bxv9v         0/1     Completed   1          11m
ingress-nginx   pod/ingress-nginx-controller-6f5454cbfb-s2w9p   1/1     Running     0          11m
kube-system     pod/coredns-f9fd979d6-6xbxs                     1/1     Running     0          19m
kube-system     pod/coredns-f9fd979d6-frrrv                     1/1     Running     0          19m
kube-system     pod/etcd-docker-desktop                         1/1     Running     0          18m
kube-system     pod/kube-apiserver-docker-desktop               1/1     Running     0          18m
kube-system     pod/kube-controller-manager-docker-desktop      1/1     Running     0          18m
kube-system     pod/kube-proxy-mfwlw                            1/1     Running     0          19m
kube-system     pod/kube-scheduler-docker-desktop               1/1     Running     0          18m
kube-system     pod/storage-provisioner                         1/1     Running     0          18m
kube-system     pod/vpnkit-controller                           1/1     Running     0          18m

NAMESPACE       NAME                                         TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
default         service/kubernetes                           ClusterIP      10.96.0.1        &lt;none&gt;        443/TCP                      19m
default         service/webapp-service                       NodePort       10.111.167.112   &lt;none&gt;        3000:30090/TCP               13m
ingress-nginx   service/ingress-nginx-controller             LoadBalancer   10.106.21.69     localhost     80:32737/TCP,443:32675/TCP   11m
ingress-nginx   service/ingress-nginx-controller-admission   ClusterIP      10.105.208.234   &lt;none&gt;        443/TCP                      11m
kube-system     service/kube-dns                             ClusterIP      10.96.0.10       &lt;none&gt;        53/UDP,53/TCP,9153/TCP       19m

NAMESPACE     NAME                        DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
kube-system   daemonset.apps/kube-proxy   1         1         1       1            1           kubernetes.io/os=linux   19m

NAMESPACE       NAME                                       READY   UP-TO-DATE   AVAILABLE   AGE
default         deployment.apps/webapp                     1/1     1            1           13m
ingress-nginx   deployment.apps/ingress-nginx-controller   1/1     1            1           11m
kube-system     deployment.apps/coredns                    2/2     2            2           19m

NAMESPACE       NAME                                                  DESIRED   CURRENT   READY   AGE
default         replicaset.apps/webapp-78d8b79b4f                     1         1         1       13m
ingress-nginx   replicaset.apps/ingress-nginx-controller-6f5454cbfb   1         1         1       11m
kube-system     replicaset.apps/coredns-f9fd979d6                     2         2         2       19m

NAMESPACE       NAME                                       COMPLETIONS   DURATION   AGE
ingress-nginx   job.batch/ingress-nginx-admission-create   1/1           1s         11m
ingress-nginx   job.batch/ingress-nginx-admission-patch    1/1           3s         11m
</code></pre>
<p>I already tried debugging, and when doing an exec to the nginx service:
<code>kubectl exec service/ingress-nginx-controller -n ingress-nginx -it -- sh</code>
I can do the following curl: <code>curl -H &quot;host:kubernetes.docker.internal&quot; localhost</code> and it returns the correct content. So to me this seems like my loadbalancer service is not used when opening <a href="http://kubernetes.docker.internal" rel="nofollow noreferrer">http://kubernetes.docker.internal</a> via the browser. I also tried using the same curl from my terminal but that had the same 'empty response' result.</p>

<p>I knew this is quite outdated thread, but i think my answer can help later visitors</p>
<p><strong>Answer</strong>: You have to install ingress controller. For exam: ingress-nginx controller,</p>
<p>either using <strong>helm</strong>:</p>
<pre><code>helm upgrade --install ingress-nginx ingress-nginx \
--repo https://kubernetes.github.io/ingress-nginx \
--namespace ingress-nginx --create-namespace
</code></pre>
<p>or <strong>kubectl</strong>:</p>
<pre><code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.2.0/deploy/static/provider/cloud/deploy.yaml
</code></pre>
<p>you can find addional info <a href="https://kubernetes.github.io/ingress-nginx/deploy/#quick-start" rel="nofollow noreferrer">here</a></p>
<p>don't forget to add defined host to <code>/etc/hosts</code> file. e.g</p>
<pre><code>127.0.0.1 your.defined.host
</code></pre>
<p>then access defined host as usual</p>
