Setup NGINX Ingress Controller

Rancher Desktop uses K3s under the hood, which in turn uses Traefik as the default ingress controller for your Kubernetes cluster. However, there are unique use cases where NGINX may be required or preferred. Below steps show how to use NGINX Ingress controller for a sample deployment.

Steps

  1. Uncheck Enable Traefik from the Kubernetes Settings page to disable Traefik. You may need to exit and restart Rancher Desktop for the change to take effect.

  2. Deploy the NGINX ingress controller via helm or kubectl.

  • helm
  • kubectl
  1. helm upgrade --install ingress-nginx ingress-nginx \
  2. --repo https://kubernetes.github.io/ingress-nginx \
  3. --namespace ingress-nginx --create-namespace
  1. kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.2/deploy/static/provider/cloud/deploy.yaml
  1. Wait for the ingress pods to come up and running.
  1. kubectl get pods --namespace=ingress-nginx
  1. Create a sample deployment and the associated service.
  1. kubectl create deployment demo --image=nginx --port=80
  2. kubectl expose deployment demo
  1. Create an ingress resource. The following command uses a host that maps to localhost.
  1. kubectl create ingress demo-localhost --class=nginx --rule="demo.localdev.me/*=demo:80"
  1. Forward a local port to the ingress controller.
  1. kubectl port-forward --namespace=ingress-nginx service/ingress-nginx-controller 8080:80

If you access http://demo.localdev.me:8080/, you should see NGINX Welcome page.