0
0
Kubernetesdevops~3 mins

Why Ingress controllers (Nginx, Traefik) in Kubernetes? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if one simple tool could handle all your app traffic without endless manual rules?

The Scenario

Imagine you have many websites and apps running on different servers. You want users to reach them all through one door, but you have to tell each server separately how to handle the traffic.

You write many rules manually for each server and update them every time something changes.

The Problem

This manual way is slow and confusing. If you forget to update a rule, users get errors or can't reach your apps.

It's hard to keep track of all the rules, and mistakes cause downtime or security risks.

The Solution

Ingress controllers like Nginx and Traefik act as smart traffic managers. They listen at one entry point and automatically send users to the right app based on simple rules.

They update themselves when you add or change apps, so you don't have to do it manually.

Before vs After
Before
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 10.0.0.1:80
iptables -t nat -A PREROUTING -p tcp --dport 81 -j DNAT --to-destination 10.0.0.2:80
After
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
spec:
  rules:
  - host: app1.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: app1-service
            port:
              number: 80
  - host: app2.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: app2-service
            port:
              number: 80
What It Enables

With ingress controllers, you can easily manage many apps behind one address, making your system simpler and more reliable.

Real Life Example

A company runs multiple web apps for customers. Using Traefik, they route all traffic through one gateway, so customers access apps by friendly URLs without complex network setup.

Key Takeaways

Manual traffic routing is slow and error-prone.

Ingress controllers automate and simplify routing rules.

This leads to easier management and better user experience.