How to use NGINX ingress controller in K3s
Tags: kubernetes, nginx, guide
Published: 2020-05-26 10:08:02

---
title: How to use NGINX ingress controller in K3s
published: true
description: NGINX is probably the most famous ingress to be used everywhere in Kubernetes, so why not use it on K3s as well?
tags: kubernetes, nginx, guide
---
The [NGINX Ingress Controller](https://www.nginx.com/products/nginx/kubernetes-ingress-controller/) is one of the most used ingresses in the Kubernetes ecosystem, being more or less the best ingress controllers out there along with [Traefik](https://containo.us/traefik/), which is the default load balancer and ingress in K3s. 

So let's say you don't want Traefik, and you want the NGINX Ingress, the answer is: **that's possible!** And its very easy to get a K3s cluster to use a NGINX Ingress Controller.

## Getting your cluster ready

First order of business is that you need to get your cluster have no other ingress controllers as this would conflict with your current ingress controllers. This is because NGINX and Traefik both listens to 80 and 443, which causes conflicts with each other, so make sure your K3s cluster only has one kind of the other.

For the best results, your K3s cluster must be installed with the `--no-deploy-traefik` argument, which will cause the K3s cluster to deploy only with the bare container orchestrator without the default HTTP backend, which is Traefik.

to make sure you don't have a Traefik controller installed, run `kubectl get deployments -n kube-system` to see if Traefik is gone. 

If you have verified Traefik is not there, then you may proceed with the next part.

## Installing NGINX

There's two ways to install NGINX, either from a Helm chart or a direct `kubectl apply -f <file>`

### Using a Helm chart

The NGINX ingress is available in the [Helm Stable Charts](https://github.com/helm/charts/tree/master/stable/nginx-ingress), and if you have the stable registry already installed in your Helm CLI, simply run `helm install stable/nginx-ingress`.

You may also modify the installation using the following configurations stated [here](https://github.com/helm/charts/tree/master/stable/nginx-ingress#configuration).

### Using the regular `kubectl`

If you don't want to use Helm, then you can use `kubectl apply`.

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

This will launch a very basic configuration of the ingress controller, with still having the option to configure it using the configmap.

## Verify if it works

Browse on your cluster's address and the all-familiar default NGINX 404 screen should greet you that it works.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vomc5vnibrjtskcsmzb8.png)

## How does it compare to Traefik?

In my perspective, not having the UI to monitor the traffic (a Traefik feature) is the only thing I missed, however, I also noticed at one point that the browser returns a `HTTP_TOO_MANY_REDIRECTS` error if you try to point it in a TLD/subdomain, which I am not yet sure why it doesn't work. 

Keep in mind this was tested in [Civo](https://civo.com) so the usual YMMV (Your Mileage May Vary) applies here.

## Conclusion

Overall, there's nothing much change for the layman's perspective and nothing's better than the other since Traefik and NGINX are equally good ingress controllers. It depends on preference on which do you like to use for your cluster and which you believe is good for your use case.

*This entire guide was tested on the [Civo Cloud Platform](https://civo.com) as part of their #Kube100 initiative. If you're interested to help them test the K3s platform, click on the link to apply!*