How apache/apisix-ingress-controller works
This project is Apache APISIX Ingress Controller – a Kubernetes control plane component that converts Kubernetes Ingress and custom resources (CRDs) into Apache APISIX configurations. The goal is to manage the Apache APISIX data plane using Kubernetes declarative configurations.
Main Components
• Ingress Controller Main Binary – represented by the “cmd” directory (e.g., cmd/ingress). This is the entry point where the controller’s main logic is initialized.
• API and Validation Layer – under pkg/api, which handles HTTP endpoints (e.g., health checks, webhook endpoints) and request validation.
• Configuration and ID Generation – found in pkg/config and pkg/id; these modules handle configuration management and unique identifier generation.
• APISIX Translation/Provider Modules – in pkg/apisix, pkg/providers (including submodules for “apisix”, “ingress”, “gateway”, etc.). These packages convert Kubernetes CRDs (e.g., ApisixRoute, ApisixConsumer, etc.) into resources understood by Apache APISIX.
• Kubernetes Integration – in pkg/kube and pkg/providers/k8s, managing the connection to and interaction with Kubernetes resources. This includes client sets, informers, listers, and event handling to watch for CRD changes.
• Caching Layer – in pkg/apisix/cache, which handles in-memory caching (with modules like memdb) to optimize read/write operations.
• Logging and Metrics – in pkg/log and pkg/metrics, for recording controller events and exposing Prometheus metrics.
• Utility Modules – for common functionality, error handling, and code generation.
External and Internal Interactions
• Apache APISIX Data Plane: Even though it’s an external system, this is where the controller pushes the translated configurations. Represent this external service as the backend that receives configuration updates.
• Internal Processing Pipeline: Illustrate how changes go from the Kubernetes integration layer into the provider/translation layers (e.g., APISIX resource conversion) before reaching the API logic that communicates with Apache APISIX.
Architectural Patterns and Principles
• Event-driven Architecture: Emphasize that the controller uses watchers/informers to react to changes in the K8s API, and then processes these events.
• Modular Provider Architecture: The provider submodules (for APISIX and gateway) show how the project can extend or adapt to multiple deployment scenarios and custom resources.