⚡ ~/naveed K8s Hub
⚡ Portfolio Home 👤 About Naveed Bio & Credentials 📫 Contact Naveed Get In Touch ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
Phase 1 — Fundamentals Module 07 of 24 Free & Open Access

Kubernetes Ingress & Ingress Controllers

An Ingress defines HTTP and HTTPS routing rules from outside the cluster to Services, and an Ingress controller such as NGINX enforces them. This module covers host and path routing, TLS termination, IngressClass, and the most common causes of a 404 or 502 from an Ingress.

Last updated: · By Naveed Ahmed, Certified Kubernetes Administrator

07 - Ingress & Ingress Controllers

Why this matters

Services alone don't give you host/path-based routing, TLS termination, or a single external entry point. Ingress does — and almost every real-world cluster runs one.

Read this first — Definitions & Explanations

Ingress

An API object that describes HTTP/HTTPS routing into the cluster (host/path rules → backend Services). It is not a server by itself.

Ingress Controller

The software that implements Ingress rules (NGINX, Traefik, HAProxy, cloud controllers). Without a controller, Ingress objects do nothing useful.

Typical flow

Internet → LoadBalancer/NodePort of controller → Ingress rules → Service → Pods

TLS on Ingress

Usually referenced via a Secret (tls.crt / tls.key). Termination often happens at the Ingress controller.

Path and host rules

IngressClass

Selects which controller should handle an Ingress when multiple controllers exist.

Official docs (read for detail)

Key Concepts

YouTube search terms

Hands-on lab (on prod-sim)

minikube addons enable ingress -p prod-sim
kubectl get pods -n ingress-nginx

kubectl create deployment app1 --image=hashicorp/http-echo -- -text="app1"
kubectl create deployment app2 --image=hashicorp/http-echo -- -text="app2"
kubectl expose deployment app1 --port=5678
kubectl expose deployment app2 --port=5678

cat <<EOF | kubectl apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: demo-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx
  rules:
  - host: app1.local
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: app1
            port:
              number: 5678
  - host: app2.local
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: app2
            port:
              number: 5678
EOF

# Route via /etc/hosts + minikube ip, or minikube tunnel for LoadBalancer-style access
minikube ip -p prod-sim
curl --resolve app1.local:80:$(minikube ip -p prod-sim) http://app1.local
curl --resolve app2.local:80:$(minikube ip -p prod-sim) http://app2.local

Common mistakes and how to avoid them

  • Creating an Ingress with no controller installed. An Ingress is only a set of rules, and nothing enforces it without a controller such as NGINX. Install one and set ingressClassName.
  • Choosing the wrong pathType. Exact matches only the exact path while Prefix matches by path segments. A mismatch shows up as unexpected 404s.
  • Pointing the Ingress at a Service with no ready endpoints. The controller finds the rule but has no backend, so clients get 502 or 503. Check kubectl get endpoints.
  • Naming a backend port that does not exist. The Ingress backend must reference a port the Service actually exposes. A wrong port gives 502.
  • Keeping the TLS Secret in another namespace. The Secret referenced in spec.tls must live in the same namespace as the Ingress.

Quick answers

What is the difference between an Ingress and an Ingress controller?

An Ingress is an API object that declares routing rules for HTTP and HTTPS traffic. An Ingress controller, such as NGINX or Traefik, is the running software that reads those rules and routes the traffic. Without a controller, an Ingress does nothing.

Why does my Ingress return 502 or 503?

The controller matched a rule but found no healthy backend. Usually the Service has no ready endpoints, the Service port in the Ingress is wrong, or the Pods fail their readiness probe. Check kubectl get endpoints and the controller logs.

How do you add TLS to an Ingress?

Store the certificate and key in a kubernetes.io/tls Secret in the same namespace, then list it under spec.tls with the hostnames. A tool such as cert-manager can issue and renew the certificate automatically from Let's Encrypt.

Notes

(fill in your own words after watching + labbing)

📋 Self-Assessment Mastery Checklist (4 Competencies)
🧠 Practice Exam Questions (Module 07 MCQs)
⚡ Take Quiz & Save Progress in Tracker

Review these sample exam questions out loud, test your retrieval, and then unlock official scoring in the interactive tracker.

Question 1: Ingress primarily provides:
  • A. L7 HTTP(S) routing into the cluster
  • B. Node disk encryption
  • C. etcd backups
  • D. CNI IPAM
✓ Correct Answer: A (L7 HTTP(S) routing into the cluster)
Option A ('L7 HTTP(S) routing into the cluster') is the standard production architectural best practice.
Question 2: An Ingress resource needs what to actually work?
  • A. Only kubectl
  • B. An Ingress Controller implementation
  • C. A DaemonSet named ingress
  • D. Helm v2 only
✓ Correct Answer: B (An Ingress Controller implementation)
Option B ('An Ingress Controller implementation') is the standard production architectural best practice.
Question 3: TLS for Ingress is commonly configured via:
  • A. A Secret referenced by the Ingress
  • B. A ConfigMap named tls-only
  • C. kube-proxy flags
  • D. NodePort 443 automatically
✓ Correct Answer: A (A Secret referenced by the Ingress)
Option A ('A Secret referenced by the Ingress') is the standard production architectural best practice.
Question 4: Path-based routing (/api vs /web) is a feature of:
  • A. ClusterIP alone
  • B. Ingress rules
  • C. PVCs
  • D. Jobs
✓ Correct Answer: B (Ingress rules)
Option B ('Ingress rules') is the standard production architectural best practice.
Question 5: Without an Ingress Controller, an Ingress object:
  • A. Still opens ports on every node
  • B. Is stored but not enforced/implemented
  • C. Deletes Services
  • D. Creates LoadBalancers automatically always
✓ Correct Answer: B (Is stored but not enforced/implemented)
Option B ('Is stored but not enforced/implemented') is the standard production architectural best practice.
← Previous Module (06) Scheduling: Affinity, Taints, Resources, PDBs Next Module (08) → Namespaces, RBAC & Security Basics