A Kubernetes Ingress is a collection of rules that allow inbound connections to reach cluster services. It can be configured to give services externally-reachable URLs, load balance traffic, terminate SSL, offer name-based virtual hosting, and more.
Nginx ingresses are pretty much the default choice for cloud-agnostic ingresses, and it was our choice as well. That is until we decided to move to Traefik to terminate HTTP(S) traffic.
As you probably know, replacing ingresses is a tricky and time-consuming process. So what drove us to do that? What was our motivation to replace nginx with Traefik? Stay tuned, because that’s exactly what I’m going to discuss in this post.
The nginx default configuration is not suited for modern REST and WebSocket APIs. After installing nginx with Helm, our site-reliability engineers had to further tweak the configuration, resulting in the waste of precious time and resources.
For example, let’s look at configuring nginx as a proxy. This requires the following additional settings:
When you have to configure your ingress for more advanced stuff, doing it with nginx can become a nightmare. Nginx lacks proper documentation, so you usually end up relying on Google and StackOverflow. Minutes turn to hours as you scroll through obscure and often outdated answers to your issues.
Traefik, on the other hand, is much easier to use and you can find extensive documentation on its website. Activating simple features with Traefik does not require multiple complex settings as it does with nginx, and the configuration itself tends to be a lot quicker and more concise as well.
While nginx settings end up in huge config maps that are hard to read and manage, it’s not an issue with Traefik. This is because Traefik allows most configurations to be set using Helm values or Kubernetes Ingress annotations.
Let’s compare for example the configurations for turning on GZip compression in nginx vs Traefik, for example.
compress = true
Here’s another example of nginx vs Traefik. Configuring the web servers to return JSON logs requires the following configurations:
Traefik has the best HTTP/2 and gRPC support we have tested. Some of our requirements include TLS termination, header-based routing, high performance, and stability, on a scale of over 10k concurrent connections. Traefik has performed much better than nginx and Istio for this use case.
The importance of monitoring your ingresses cannot be overstressed. They are the face of your application as seen by the world and are the main, and possibly the only place you can discern your app’s health.
The free open-source nginx version does not support proper monitoring, and this is a huge disadvantage. To be fair, nginx Plus offers much better monitoring features. Its price tag, however, simply could not be justified by our needs.
People are creatures of habit, and as it happens, the startups we create inherit that quality from us as well. As a startup, you often find yourself setting up your infrastructure with the good old tools you’ve been using in a former life. However, it’s important to question your choices and see if better options are available.
We arrived at the conclusion that nginx didn’t age well. It couldn’t align with our monitoring and observability needs as well as protocol support and ease of use. We saw that putting in some time and effort into moving to Traefik will be worth it in the long run, and so we did it. If your conclusion is similar, making this move should be a worthwhile investment for you as well.