Cloud Native 8 min read

Mastering Kubernetes Ingress: Controllers, Architecture, and Lua Extensions

This article explains Kubernetes Ingress fundamentals, compares major Ingress controllers such as Nginx, Kong, Traefik, HAProxy and APISIX, and details the internal architecture and Lua‑based extension points of the ingress‑nginx controller, providing a comprehensive guide for managing external traffic in cloud‑native environments.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Mastering Kubernetes Ingress: Controllers, Architecture, and Lua Extensions

1. Overview of Ingress

Ingress is a collection of routing rules that expose services inside a cluster to users via layer‑7 protocols. It is a default Kubernetes resource that defines HTTP/HTTPS rules for external traffic, allowing administrators to control inbound traffic to the cluster.

2. Ingress Definitions

Ingress resource : an API object usually configured with YAML, defining how requests are forwarded to services.

Ingress‑controller : the component that manages L4/L7 traffic entering or leaving the cluster, parses Ingress rules and performs request forwarding.

3. Popular Ingress Controllers

Kubernetes Ingress Nginx : official recommendation, based on Nginx with Lua plugins; easy to start but reload can be slow with many configs.

Nginx Ingress : developed by NGINX, built on NGINX Plus; high stability, supports TCP/UDP, but lacks some auth and traffic‑scheduling features.

Kong Ingress : extends Nginx with Lua modules, adds advanced routing, upstream probing, and authentication; provides CRDs to sync with Kong.

Traefik Ingress : full‑featured edge router with live config reload, multiple load‑balancing algorithms, Web UI, metrics, REST API, canary releases, and built‑in Let's Encrypt support.

HAProxy Ingress : leverages HAProxy’s load‑balancing strengths, offers soft config updates, DNS‑based service discovery, and customizable ConfigMap templates.

APISIX Ingress : emerging controller comparable to Kong, strong routing and plugin extensibility, excellent performance, but limited real‑world cases and documentation.

4. Ingress‑Nginx Architecture

Ingress Nginx architecture diagram
Ingress Nginx architecture diagram

The runtime consists of three main components: NginxController , Store , and SyncQueue .

Store watches the Kubernetes API server, captures changes to resources such as Ingress and Service, and writes events into a circular buffer.

NginxController listens to the update channel; when a configuration change arrives it pushes a request into SyncQueue .

SyncQueue processes tasks by:

Periodically scanning the queue and executing update operations.

Using Store to fetch the latest runtime data.

After processing, a new Nginx configuration is generated; if a reload is required, the new file is written locally and Nginx is reloaded.

5. Lua Extensions in Ingress‑Nginx

Lua scripts are embedded to provide flexible extensions. The main phases are:

init_by_lua* : runs when Nginx starts or reloads, initializing Lua environment.

init_worker_by_lua* : executed for each worker process, often used for periodic tasks such as health checks.

ssl_certificate_by_lua* : handles HTTPS requests, allowing per‑request certificate selection.

set_by_lua* : sets Nginx variables.

rewrite_by_lua* : rewrites URLs or performs redirects.

access_by_lua* : processes requests during the access phase.

content_by_lua* : runs business logic and generates responses, similar to a servlet.

balancer_by_lua* : performs load‑balancing decisions.

header_filter_by_lua* : modifies response headers.

body_filter_by_lua* : modifies response bodies.

log_by_lua* : writes access logs.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Cloud NativeKubernetesNginxIngressControllers
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.