Enable Ingress controller on Docker Desktop with WLS2 Enable Ingress controller on Docker Desktop with WLS2 kubernetes kubernetes

Enable Ingress controller on Docker Desktop with WLS2


Finally I found the way to fix. I have to deploy ingress Nginx by command:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.41.2/deploy/static/provider/cloud/deploy.yaml

(Follows the instruction at https://kubernetes.github.io/ingress-nginx/deploy/#docker-for-mac. It works just fine for Docker for Windows)

Now I can access http://ingress.local successfully.


You have to install an ingress-nginx controller on your cluster, so that your nodes will have an opened port 80/443.

Using helm (v3 - see documentation):

helm install --namespace kube-system nginx ingress-nginx --repo https://kubernetes.github.io/ingress-nginx

Using kubectl (see documentation):

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.43.0/deploy/static/provider/cloud/deploy.yaml

Then manually adding your ingresses' hostnames to /etc/hosts:

127.0.0.1     ingress.local127.0.0.1     my.other.service.local# ...

Then if you make a request on http://ingress.local:

  • the DNS resolution will route to your cluster node
  • then the ingress controller will serve the request on port 80
  • then ingress will route the request to the configured backend service
  • and the service will route to an available pod


The newest version of Docker Desktop for Windows already adds a hosts file entry: 127.0.0.1 kubernetes.docker.internal.

You had to do use kubernetes.docker.internal URL as a hostname in Ingress definition if you want to point to 127.0.0.1. This should be in the docs on this page kubernetes.github.io/ingress-nginx/deploy but there is no Docker Desktop for Windows section there.Your files should look like this:

apiVersion: v1kind: Servicemetadata:  name: webapp-servicespec:  type: NodePort  selector:    app: webapp  ports:  - name: http    protocol: TCP    port: 3000    nodePort: 30090

Your Ingress file should look like this:

apiVersion: extensions/v1beta1kind: Ingressmetadata:  name: webapp-ingress spec:  rules:  - host: kubernetes.docker.internal    http:      paths:      - path: /        backend:          serviceName: webapp-service           servicePort: http

Then you are able to connect to app using http://kubernetes.docker.internal/.

Example you can see here: wsl2-docker-for-desktop.