|
| 1 | +<!-- cspell:disable --> |
| 2 | +# Envoy Configuration Documentation |
| 3 | + |
| 4 | +**Purpose:** |
| 5 | +This Envoy proxy configuration manages traffic routing to internal and external services, such as Azure Cosmos DB endpoints, while exposing local admin metrics. It enforces strict retry logic, TLS encryption, and structured access logging. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Listeners |
| 10 | + |
| 11 | +### 1. `admin-listener` (Port `8080`) |
| 12 | + |
| 13 | +**Purpose:** Handles health checks and Prometheus metrics access for observability. |
| 14 | + |
| 15 | +**Routes:** |
| 16 | + |
| 17 | +| Path | Action | |
| 18 | +|------------|------------------------------------------| |
| 19 | +| `/ready` | Routed to `admin_port_cluster` | |
| 20 | +| `/metrics` | Routed to `admin_port_cluster` with `prefix_rewrite: /stats/prometheus` | |
| 21 | +| `*` | Returns HTTP 404 (direct response) | |
| 22 | + |
| 23 | +**HTTP Filter Chain:** |
| 24 | +- Uses `envoy.filters.http.router` |
| 25 | +- Enables `respect_expected_rq_timeout: true` to support `x-envoy-expected-rq-timeout-ms` header. |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +### 2. `main-listener` (Port `5100`) |
| 30 | + |
| 31 | +**Purpose:** Handles user/application traffic and routes to various external services including Azure Cosmos DB regions. |
| 32 | + |
| 33 | +**Key Settings:** |
| 34 | +- **Stat Prefix:** `router_http` |
| 35 | +- **Scheme Overwrite:** Forces outgoing requests to use `https` (`scheme_header_transformation`) |
| 36 | +- **Strip Host Ports:** Enabled (`strip_any_host_port: true`) |
| 37 | +- **Node ID-based Proxy Status:** Enabled |
| 38 | + |
| 39 | +**Timeouts and Limits:** |
| 40 | + |
| 41 | +| Setting | Value | |
| 42 | +|----------------------------|---------| |
| 43 | +| Max Connection Duration | 900s | |
| 44 | +| Drain Timeout | 330s | |
| 45 | +| Stream Idle Timeout | 60s | |
| 46 | +| Max Request Header Size | 120 KB | |
| 47 | + |
| 48 | +**Response Header Modification:** |
| 49 | +- Adds: `via: %ENVIRONMENT(POD_NAME)%` (for traceability) |
| 50 | + |
| 51 | +**HTTP Filters:** |
| 52 | +- Only one: `envoy.filters.http.router`, with retry logic support. |
| 53 | + |
| 54 | +**Routes:** |
| 55 | + |
| 56 | +| Name | Domains | Cluster | Retry Policy | |
| 57 | +|---------------------------------------|-------------------------------|-----------|-----------------------------------------------| |
| 58 | +| `local_<account_name>` | `*` | `<>` | `connect-failure,refused-stream,reset`, 3 retries | |
| 59 | +| `local_<account_name>-<write_region>` | `<account_name>-<write_region>.documents.azure.com` | `<account_name>-<write_region>` | Same | |
| 60 | +| `local_<account_name>-<read_region>` | `<account_name>-<read_region>.documents.azure.com` | `<account_name>-<read_region>` | Same | |
| 61 | +| `local_heise` | `www.heise.de` | `heise` | Same | |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## Request Routing Flow (Mermaid Diagram) |
| 66 | + |
| 67 | +```mermaid |
| 68 | +graph TD |
| 69 | + A[Incoming Request] --> B{Listener} |
| 70 | + B -->|Port 8080| C[admin-listener] |
| 71 | + B -->|Port 5100| D[main-listener] |
| 72 | +
|
| 73 | + C --> E{Path} |
| 74 | + E -->|/ready| F[Route to admin_port_cluster] |
| 75 | + E -->|/metrics| G[Rewrite + Route to admin_port_cluster] |
| 76 | + E -->|other| H[Return 404] |
| 77 | +
|
| 78 | + D --> I{Domain/Prefix Match} |
| 79 | + I -->|\*| J[Route to Cluster account_name] |
| 80 | + I -->|account_name-write_region.documents.azure.com| K[Route to Cluster account_name-write_region] |
| 81 | + I -->|account_name-read_region.documents.azure.com| L[Route to Cluster account_name-read_region] |
| 82 | + I -->|www\.heise.de| M[Route to Cluster heise] |
| 83 | +``` |
0 commit comments