# kubernetes/ingress-nginx architecture

> Architecture diagram of the GitHub repository kubernetes/ingress-nginx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kubernetes/ingress-nginx
- Repository: https://github.com/kubernetes/ingress-nginx

## Overview

##### Main Components

a. Core Components:
- Ingress Controller (Control Plane)
- NGINX Data Plane
- Kubernetes API Server Interface
- Dynamic Configuration Handler
- Metrics/Monitoring System
- Lua Runtime Environment

b. Supporting Components:
- Certificate Manager
- TCP/UDP Load Balancer
- Health Checker
- Status Updater
- Admission Controller

##### Architectural Layers

Layer 1 - External Traffic:
- Client Traffic Entry Points
- Load Balancer (Cloud or Bare Metal)
- SSL/TLS Termination Points

Layer 2 - Ingress Processing:
- NGINX Reverse Proxy
- Traffic Routing Rules
- Load Balancing Algorithms
- SSL Passthrough

Layer 3 - Controller Logic:
- Configuration Sync
- Dynamic Updates
- Service Discovery
- Health Monitoring

Layer 4 - Kubernetes Integration:
- API Watch Mechanisms
- ConfigMap Processing
- Secret Management
- Service Backend Discovery

##### Key Relationships

- Traffic Flow:
- External Traffic → Ingress → Services
- Control Plane → Data Plane Updates
- Configuration Changes → NGINX Reloads

- Data Flow:
- Certificate Updates
- Configuration Changes
- Metrics Collection
- Health Status Updates

##### Implementation Details

Implementation aspects:
- Configuration reload mechanism
- Dynamic certificate handling
- Load balancing strategies
- Health check implementation
- Metrics collection points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "External Layer"
        CLIENT[Client Traffic]
        ELB[External Load Balancer]
        TLS[SSL/TLS Termination]:::security
    end

    subgraph "Ingress Processing Layer"
        NGINX[NGINX Reverse Proxy]:::core
        TCPUDP["TCP/UDP Load Balancer"]:::core
        LUA["Lua Runtime Environment"]:::core
        BALANCER["Load Balancing Algorithms"]:::core
    end

    subgraph "Controller Layer"
        CTRL["Ingress Controller"]:::controller
        DYNCONF["Dynamic Configuration Handler"]:::controller
        HEALTH["Health Checker"]:::controller
        STATUS["Status Updater"]:::controller
        CERTMGR["Certificate Manager"]:::security
        METRICS["Metrics/Monitoring"]:::monitoring
    end

    subgraph "Kubernetes Integration Layer"
        K8SAPI["Kubernetes API Interface"]:::k8s
        ADMIT["Admission Controller"]:::k8s
        CONFMAP[("ConfigMaps")]:::storage
        SECRETS[("Secrets")]:::storage
    end

    %% External Layer Connections
    CLIENT --> ELB
    ELB --> TLS
    TLS --> NGINX

    %% Ingress Processing Layer Connections
    NGINX --> TCPUDP
    NGINX --> LUA
    LUA --> BALANCER

    %% Controller Layer Connections
    CTRL --> NGINX
    CTRL --> DYNCONF
    CTRL --> HEALTH
    CTRL --> STATUS
    CTRL --> CERTMGR
    CTRL --> METRICS

    %% Kubernetes Integration Layer Connections
    K8SAPI --> CTRL
    ADMIT --> CTRL
    CONFMAP --> CTRL
    SECRETS --> CERTMGR

    %% Click events for component mapping
    click CTRL "https://github.com/kubernetes/ingress-nginx/tree/main/internal/ingress/controller/"
    click NGINX "https://github.com/kubernetes/ingress-nginx/tree/main/cmd/nginx/"
    click DYNCONF "https://github.com/kubernetes/ingress-nginx/blob/main/rootfs/etc/nginx/lua/configuration.lua"
    click METRICS "https://github.com/kubernetes/ingress-nginx/tree/main/internal/ingress/metric/"
    click LUA "https://github.com/kubernetes/ingress-nginx/tree/main/rootfs/etc/nginx/lua/"
    click CERTMGR "https://github.com/kubernetes/ingress-nginx/blob/main/internal/ingress/controller/certificate.go"
    click TCPUDP "https://github.com/kubernetes/ingress-nginx/blob/main/pkg/tcpproxy/tcp.go"
    click HEALTH "https://github.com/kubernetes/ingress-nginx/blob/main/internal/ingress/controller/checker.go"
    click STATUS "https://github.com/kubernetes/ingress-nginx/blob/main/internal/ingress/status/status.go"
    click ADMIT "https://github.com/kubernetes/ingress-nginx/tree/main/internal/admission/controller/"
    click K8SAPI "https://github.com/kubernetes/ingress-nginx/tree/main/internal/k8s/"
    click BALANCER "https://github.com/kubernetes/ingress-nginx/tree/main/rootfs/etc/nginx/lua/balancer/"
    click TLS "https://github.com/kubernetes/ingress-nginx/tree/main/internal/net/ssl/"

    %% Styling
    classDef core fill:#2374e1,color:#fff
    classDef controller fill:#37474f,color:#fff
    classDef security fill:#ff7043,color:#fff
    classDef k8s fill:#00796b,color:#fff
    classDef monitoring fill:#ffd54f,color:#000
    classDef storage fill:#90a4ae,color:#000

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Controller Components]:::controller
        L3[Security Components]:::security
        L4[Kubernetes Components]:::k8s
        L5[Monitoring]:::monitoring
        L6[Storage]:::storage
    end
```
