<p>I'm trying to do a straight up thing that I would think is simple. I need to have <a href="https://localhost:44301" rel="nofollow noreferrer">https://localhost:44301</a>, <a href="https://localhost:5002" rel="nofollow noreferrer">https://localhost:5002</a>, <a href="https://localhost:5003" rel="nofollow noreferrer">https://localhost:5003</a> to be listened to in my k8s environment in docker desktop, and be proxied using a pfx file/password that I specify and have it forward by the port to pods listening on specific addresses (could be port 80, doesn't matter)</p>

<p>The documentation is mind numbingly complex for what looks like it should be straight forward. I can get the pods running, I can use kubectl port-forward and they work fine, but I can't figure out how to get ingress working with ha-proxy or nginx or anything else in a way that makes any sense.</p>

<p>Can someone do an ELI5 telling me how to turn this on? I'm on Windows 10 2004 with WSL2 and Docker experimental so I should have access to the ingress stuff they reference in the docs and make clear as mud.</p>

<p>Thanks!</p>

James Hancock
<p>As discussed in the comments this is a community wiki answer:</p>

<hr>

<p>I have managed to create Ingress resource in Kubernetes on Docker in Windows. </p>

<p><strong>Steps to reproduce</strong>: </p>

<ul>
<li>Enable Hyper-V </li>
<li>Install Docker for Windows and enable Kubernetes </li>
<li>Connect kubectl </li>
<li>Enable Ingress </li>
<li>Create deployment</li>
<li>Create service</li>
<li>Create ingress resource </li>
<li>Add host into local hosts file </li>
<li>Test </li>
</ul>

<h3>Enable <a href="https://learn.microsoft.com/pl-pl/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v" rel="noreferrer">Hyper-V</a></h3>

<p>From Powershell with administrator access run below command: </p>

<p><code>Enable-WindowsOptionalFeature -Online -FeatureName  Microsoft-Hyper-V -All</code></p>

<p>System could ask you to reboot your machine.</p>

<h3>Install Docker for Windows and enable Kubernetes</h3>

<p>Install Docker application with all the default options and enable Kubernetes </p>

<h3>Connect kubectl</h3>

<p>Install <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl-on-windows" rel="noreferrer">kubectl </a>. </p>

<h3>Enable Ingress</h3>

<p>Run this commands: </p>

<pre><code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
</code></pre>

<pre><code>kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/cloud-generic.yaml
</code></pre>

<h3><strong>Edit:</strong> Make sure no other service is using port 80</h3>

<p>Restart your machine. From a <code>cmd</code> prompt running as admin, do:
<code>net stop http</code>
Stop the listed services using <code>services.msc</code></p>

<p>Use: <code>netstat -a -n -o -b</code> and check for other processes listening on port 80.</p>

<h3>Create deployment</h3>

<p>Below is simple deployment with pods that will reply to requests: </p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello
spec:
  selector:
    matchLabels:
      app: hello
      version: 2.0.0
  replicas: 3
  template:
    metadata:
      labels:
        app: hello
        version: 2.0.0
    spec:
      containers:
      - name: hello
        image: "gcr.io/google-samples/hello-app:2.0"
        env:
        - name: "PORT"
          value: "50001"
</code></pre>

<p>Apply it by running command: </p>

<p><code>$ kubectl apply -f file_name.yaml</code></p>

<h3>Create service</h3>

<p>For pods to be able for you to communicate with them you need to create a service. </p>

<p>Example below: </p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: hello-service
spec:
  type: NodePort
  selector:
    app: hello
    version: 2.0.0
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: 50001
</code></pre>

<p>Apply this service definition by running command: </p>

<p><code>$ kubectl apply -f file_name.yaml</code></p>

<h3>Create Ingress resource</h3>

<p>Below is simple Ingress resource using service created above: </p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: hello-ingress 
spec:
  rules:
  - host: kubernetes.docker.internal
    http:
      paths:
      - path: /
        backend:
          serviceName: hello-service 
          servicePort: http
</code></pre>

<p>Take a look at:</p>

<pre class="lang-yaml prettyprint-override"><code>spec:
  rules:
  - host: hello-test.internal 
</code></pre>

<p><code>hello-test.internal</code> will be used as the <code>hostname</code> to connect to your pods. </p>

<p>Apply your Ingress resource by invoking command: </p>

<p><code>$ kubectl apply -f file_name.yaml</code></p>

<h3>Add host into local hosts file</h3>

<p>I found this <a href="https://github.com/docker/for-win/issues/1901" rel="noreferrer">Github link </a> that will allow you to connect to your Ingress resource by <code>hostname</code>.</p>

<p>To achieve that add a line <code>127.0.0.1 hello-test.internal</code> to your <code>C:\Windows\System32\drivers\etc\hosts</code> file and save it. 
You will need Administrator privileges to do that.</p>

<p><strong>Edit:</strong> The newest version of Docker Desktop for Windows already adds a hosts file entry:
<code>127.0.0.1 kubernetes.docker.internal</code></p>

<h3>Test</h3>

<p>Display the information about Ingress resources by invoking command: 
<code>kubectl get ingress</code></p>

<p>It should show: </p>

<pre><code>NAME            HOSTS                 ADDRESS     PORTS   AGE
hello-ingress   hello-test.internal   localhost   80      6m2s
</code></pre>

<p>Now you can access your Ingress resource by opening your web browser and typing </p>

<p><code>http://kubernetes.docker.internal/</code> </p>

<p>The browser should output: </p>

<pre><code>Hello, world!
Version: 2.0.0
Hostname: hello-84d554cbdf-2lr76
</code></pre>

<p><code>Hostname: hello-84d554cbdf-2lr76</code> is the name of the pod that replied. </p>

<p>If this solution is not working please check connections with the command: 
<code>netstat -a -n -o</code> 
(<strong>with Administrator privileges</strong>) if something is not using port 80. </p>

<hr>
