CHAPTER 11
Intermediate
Kubernetes Ingress Controller
Updated: May 15, 2026
25 min read
# CHAPTER 11
Kubernetes Ingress Controller
1. Introduction
In Chapter 7, we exposed applications usingNodePort and LoadBalancer Services. However, at an enterprise scale, this approach is deeply flawed. If you have 50 different microservices (a Blog, a Store, an API), provisioning 50 different Cloud Load Balancers will cost you thousands of dollars a month, and mapping 50 different IP addresses is a DNS nightmare. To solve this, Kubernetes introduces Ingress: a smart, single front door that routes incoming web traffic to the correct internal services based on URLs and paths.
2. Learning Objectives
By the end of this chapter, you will be able to:- Identify the architectural flaws of relying solely on LoadBalancer services.
- Define what an Ingress and an Ingress Controller are.
- Understand path-based and host-based routing rules.
- Enable the NGINX Ingress Controller in Minikube.
- Author an Ingress YAML manifest.
3. Beginner-Friendly Explanation
Imagine an massive apartment building with 50 different businesses inside.- The Old Way (LoadBalancers): You build 50 different physical front doors on the street. Each door goes straight to one business. It takes up the entire city block, and it's incredibly expensive to build.
- The Ingress Way: You build exactly ONE grand front entrance (The Ingress Controller). Inside the entrance sits a highly intelligent receptionist (The Ingress Rules).
-
A customer walks in and says, "I am looking for
website.com/blog." The receptionist checks their rulebook and sends them to Room 101.
-
The next customer says, "I am looking for
api.website.com." The receptionist sends them to Room 505.
4. Ingress vs. Ingress Controller
This is a massive point of confusion for beginners:- Ingress Controller: The actual software doing the heavy lifting (usually NGINX, HAProxy, or Traefik). It is a Pod running in your cluster that listens to external traffic. *Kubernetes does NOT come with an Ingress Controller by default! You must install one.*
-
Ingress (The Object): The YAML file (The Rulebook) that you give to the Controller. It contains the instructions: "Route
/loginto the Auth Service."
5. Enabling Ingress in Minikube
Because Kubernetes doesn't have a default controller, Minikube provides a convenient add-on that instantly installs the industry-standard NGINX Ingress Controller. Open your terminal and run:
bash
*(Minikube will download and launch the NGINX controller Pods in the ingress-nginx namespace).*
6. Anatomy of an Ingress YAML
Once the controller is running, we feed it a rulebook. This YAML tells the controller: If a request comes in formyapp.com/api, send it to the api-service on port 3000.
yaml
7. Mini Project: Path-Based Routing
Let's route traffic to two different applications using a single IP address.Step-by-Step Tutorial:
- 1. Ensure the Ingress addon is enabled (Section 5).
- 2. We need two services. Let's launch a "Blue" app and a "Red" app using imperative commands for speed:
bash
-
3.
Create an
ingress.yamlfile to route the traffic:
yaml
-
4.
Apply it:
kubectl apply -f ingress.yaml
-
5.
Test it: Ask Minikube for the IP address of the Ingress Controller:
minikube ip. (Let's assume it returns192.168.49.2).
-
6.
Open your browser to
http://192.168.49.2/blue. You will see "BLUE-APP". Change the URL to/redand you will see "RED-APP". One IP address gracefully routing to two entirely different microservices!
8. Real-World Scenarios
Ingress Controllers are the gatekeepers of enterprise security. Instead of configuring SSL/TLS certificates on 50 different microservices, the DevOps engineer installs a tool calledcert-manager into the cluster. cert-manager automatically requests a free SSL certificate from Let's Encrypt and attaches it directly to the NGINX Ingress Controller. The Ingress handles all the complex HTTPS decryption at the front door (SSL Termination), and passes standard HTTP traffic safely to the backend Pods, saving massive amounts of compute power.
9. Best Practices
-
Host-Based Routing: In the real world, you rarely use raw IPs. You use
hostrouting. You can configure your Ingress so thatblog.company.comroutes to the WordPress service, andapp.company.comroutes to the React service, all utilizing the exact same physical IP address.
10. Common Mistakes
-
Applying Ingress Rules Without a Controller: Beginners often write perfect
ingress.yamlfiles, apply them, and then spend hours wondering why they get a "Page Not Found" error in the browser. The API Server accepts the Ingress rules perfectly, but if you forgot to install the actual NGINX Ingress Controller software into the cluster, there is no "receptionist" to actually enforce the rules!
11. Exercises
-
1.
What is the fundamental financial and architectural advantage of utilizing a single Ingress Controller over deploying 20 Cloud
LoadBalancerservices?
- 2. Differentiate between an "Ingress" (the Kubernetes object) and an "Ingress Controller".
12. FAQs
Q: Do I have to use NGINX? A: No. While NGINX is the most popular, there are many controllers. AWS users often use the ALB (Application Load Balancer) Ingress Controller. Traefik and HAProxy are also highly popular alternatives that offer different feature sets regarding dynamic routing and observability.13. Interview Questions
- Q: Explain the concept of SSL Termination. How does an Ingress Controller facilitate SSL Termination within a Kubernetes microservice architecture?
-
Q: A developer has successfully applied an Ingress manifest defining path-based routing (
/apitoapi-serviceand/webtoweb-service). However, all external traffic is returning a generic 404 error from NGINX. Describe the architectural checks you would perform to debug this routing failure.