|
2 | 2 |
|
3 | 3 | This document provides guidance for AI coding agents working with the cluster-ingress-operator repository. |
4 | 4 |
|
| 5 | +## 1. SYSTEM CONTEXT & TOPOLOGY |
| 6 | +* **Domain:** North-South network traffic management (Layer 7 & Layer 4). |
| 7 | +* **Prerequisites:** CNI (Cluster Network Operator), Pod IP routing, internal CoreDNS. |
| 8 | +* **Dual Architecture Mode:** |
| 9 | + 1. **Legacy/Primary:** HAProxy orchestration via `openshift3/ose-haproxy-router`. |
| 10 | + 2. **Modern/GWAPI:** Gateway API via OpenShift Service Mesh (OSSM / Istio / Envoy). |
| 11 | + |
| 12 | +## 2. STRICT NAMESPACE BOUNDARIES |
| 13 | +* **`openshift-ingress-operator`**: Execution environment for operator logic, control loops, and metrics endpoints. **DO NOT** deploy data-plane operands here. |
| 14 | +* **`openshift-ingress`**: Execution environment for all data-plane workloads. HAProxy pods, `haproxy.cfg` ConfigMaps, TLS secrets, Envoy proxies, and Services **MUST** be strictly confined to this namespace. |
| 15 | + |
| 16 | +## 3. CUSTOM RESOURCE DEFINITION (CRD) MATRIX |
| 17 | + |
| 18 | +### Core Configuration |
| 19 | +* **`Ingress`** (`config.openshift.io/v1`, Cluster-scoped): Defines cluster-wide routing defaults and toggles. |
| 20 | +* **`IngressController`** (`operator.openshift.io/v1`, Namespace-scoped): Primary interface for legacy HAProxy. Controls replicas, deployment affinity, and endpoint publishing. |
| 21 | +* **`DNSRecord`** (`ingress.operator.openshift.io/v1`, Namespace-scoped): Internal abstraction for cloud DNS manipulation. |
| 22 | + |
| 23 | +### Gateway API (GWAPI) |
| 24 | +* **`GatewayClass`**: Trigger resource. Detecting `openshift.io/gateway-controller/v1` initiates OSSM deployment. |
| 25 | +* **`Gateway`**: Defines external proxy instances / ports. Mapped to Envoy proxies. |
| 26 | +* **`HTTPRoute`**: Advanced routing, traffic weighting, and header matching to backend services. |
| 27 | + |
| 28 | +## 4. DIRECTORY TOPOGRAPHY |
| 29 | +* `pkg/operator/controller/ingress/`: Legacy core. Reconciles `IngressController` and manages HAProxy deployment, load balancer services, and status loops. |
| 30 | +* `pkg/operator/controller/dns/`: Fulfills `DNSRecord` resources. Interfaces with AWS/GCP/Azure SDKs. |
| 31 | +* `pkg/operator/controller/gatewayapi/`: GWAPI meta-controller. Manages CRD lifecycles and launches dependent watchers. |
| 32 | +* `pkg/operator/controller/gatewayclass/`: Provisions OSSM and generates the `ServiceMeshControlPlane`. |
| 33 | +* `pkg/operator/controller/certificate/`: Manages automated certificate rotation and expiry. |
| 34 | + |
| 35 | +## 5. TACTICAL DIRECTIVES & CONSTRAINTS |
| 36 | +* **RULE 1: No Silent Failures.** If a cloud API times out or a version conflict occurs, set the expected error condition in `.status.conditions` (`expectedCondition` in `status.go`) and mark the operator as `Degraded`. |
| 37 | +* **RULE 2: OSSM Meta-Management for GWAPI.** The operator does not write Envoy configs directly. It manages the OpenShift Service Mesh Operator by generating a `ServiceMeshControlPlane` (SMCP) resource. |
| 38 | +* **RULE 3: Decouple DNS for GWAPI.** Directly generate `DNSRecord` objects for GWAPI endpoints; do not tie external endpoints for Envoy to the legacy HAProxy `IngressController`. |
| 39 | +* **RULE 4: Finalizer Management.** Explicitly handle the removal of finalizers (e.g., `ingress.openshift.io/operator`) during deletion workflows in `load_balancer_service.go` to prevent infinite `Terminating` states. |
| 40 | +* **RULE 5: Cloud Credential Operator (CCO) Awareness.** Gracefully degrade and report HTTP 403 Forbidden errors if assumed roles lack permissions in "manual mode" where dynamic IAM credentials are disabled. |
| 41 | +* **RULE 6: Immutable HAProxy Template.** Do not inject arbitrary, unsupported HAProxy directives into the base router template. |
| 42 | + |
| 43 | +## 6. EXPLICIT NON-GOALS |
| 44 | +* Managing underlying cloud infrastructure subnets or legacy security groups. |
| 45 | +* Fixing application-level protocol downgrade failures (e.g., HTTP/2 to WebSocket). |
| 46 | +* Generating default TLS certificates for Envoy proxies. |
| 47 | + |
5 | 48 | ## Project Structure and Repository Layout |
6 | 49 |
|
7 | 50 | ``` |
|
0 commit comments