|
| 1 | +# Deployment Scenarios |
| 2 | + |
| 3 | +This document shows common deployment patterns for Agoda.DevExTelemetry and how telemetry clients connect in each case. |
| 4 | + |
| 5 | +## Scenario A: Single-host Docker Compose (small team / PoC) |
| 6 | + |
| 7 | +- API and PostgreSQL run on one host. |
| 8 | +- Good for quick validation and small-team internal usage. |
| 9 | + |
| 10 | +```mermaid |
| 11 | +flowchart LR |
| 12 | + DevMachines["Developer machines<br/>(build/test clients)"] -->|HTTP metrics| API["DevExTelemetry API<br/>Docker container"] |
| 13 | + API --> DB[("PostgreSQL<br/>Docker volume")] |
| 14 | +``` |
| 15 | + |
| 16 | +### Example `docker-compose.yml` |
| 17 | + |
| 18 | +```yaml |
| 19 | +services: |
| 20 | + app: |
| 21 | + image: agoda/devex-telemetry:latest |
| 22 | + ports: |
| 23 | + - "8080:8080" |
| 24 | + environment: |
| 25 | + - POSTGRES_CONNECTION_STRING=Host=db;Port=5432;Database=devex_telemetry;Username=devex;Password=devex |
| 26 | + depends_on: |
| 27 | + - db |
| 28 | + |
| 29 | + db: |
| 30 | + image: postgres:17-alpine |
| 31 | + environment: |
| 32 | + POSTGRES_DB: devex_telemetry |
| 33 | + POSTGRES_USER: devex |
| 34 | + POSTGRES_PASSWORD: devex |
| 35 | + volumes: |
| 36 | + - pgdata:/var/lib/postgresql/data |
| 37 | + ports: |
| 38 | + - "5432:5432" |
| 39 | + |
| 40 | +volumes: |
| 41 | + pgdata: |
| 42 | +``` |
| 43 | +
|
| 44 | +### Pros |
| 45 | +- Fastest setup |
| 46 | +- Minimal infra dependencies |
| 47 | +
|
| 48 | +### Cons |
| 49 | +- Single host is a SPOF |
| 50 | +- Limited scaling |
| 51 | +
|
| 52 | +--- |
| 53 | +
|
| 54 | +## Scenario B: Kubernetes + Helm (app) with externally managed PostgreSQL |
| 55 | +
|
| 56 | +- App is deployed to Kubernetes via Helm. |
| 57 | +- PostgreSQL is managed externally (Azure Database for PostgreSQL / RDS / Cloud SQL / internal managed DB). |
| 58 | +- App receives DB connectivity via `POSTGRES_CONNECTION_STRING` in Helm values. |
| 59 | + |
| 60 | +```mermaid |
| 61 | +flowchart LR |
| 62 | + Clients["Developer machines"] --> DNS["Internal DNS<br/>compilation-metrics"] |
| 63 | + DNS --> Ingress["K8s Ingress / Internal LB"] |
| 64 | + Ingress --> App["DevExTelemetry API<br/>Kubernetes pods"] |
| 65 | + App --> DB[("Managed PostgreSQL<br/>outside cluster")] |
| 66 | +``` |
| 67 | + |
| 68 | +### Minimal Helm chart (app layer) |
| 69 | + |
| 70 | +#### `Chart.yaml` |
| 71 | + |
| 72 | +```yaml |
| 73 | +apiVersion: v2 |
| 74 | +name: devex-telemetry |
| 75 | +version: 0.1.0 |
| 76 | +appVersion: "latest" |
| 77 | +``` |
| 78 | + |
| 79 | +#### `values.yaml` |
| 80 | + |
| 81 | +```yaml |
| 82 | +image: |
| 83 | + repository: agoda/devex-telemetry |
| 84 | + tag: latest |
| 85 | + pullPolicy: IfNotPresent |
| 86 | +
|
| 87 | +replicaCount: 2 |
| 88 | +
|
| 89 | +service: |
| 90 | + type: ClusterIP |
| 91 | + port: 8080 |
| 92 | +
|
| 93 | +ingress: |
| 94 | + enabled: true |
| 95 | + className: nginx |
| 96 | + host: devex-telemetry.internal.example.com |
| 97 | +
|
| 98 | +env: |
| 99 | + POSTGRES_CONNECTION_STRING: "Host=managed-pg.internal;Port=5432;Database=devex_telemetry;Username=devex;Password=***" |
| 100 | +``` |
| 101 | + |
| 102 | +#### `templates/deployment.yaml` (env excerpt) |
| 103 | + |
| 104 | +```yaml |
| 105 | +env: |
| 106 | + - name: POSTGRES_CONNECTION_STRING |
| 107 | + value: {{ .Values.env.POSTGRES_CONNECTION_STRING | quote }} |
| 108 | +``` |
| 109 | + |
| 110 | +### Pros |
| 111 | +- Better scalability and operability |
| 112 | +- Clean separation between app runtime and managed database |
| 113 | + |
| 114 | +### Cons |
| 115 | +- Requires Kubernetes + Helm + ingress setup |
| 116 | +- Requires platform/DNS coordination |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Scenario C: SQLite-only Docker Compose (ultra-simple local setup) |
| 121 | + |
| 122 | +- Runs only the app container. |
| 123 | +- Uses SQLite file storage inside a mounted Docker volume. |
| 124 | +- Best for solo usage, demos, and very small temporary setups. |
| 125 | +- **For development and testing only — not for production use.** |
| 126 | + |
| 127 | +```mermaid |
| 128 | +flowchart LR |
| 129 | + DevMachines["Developer machines"] -->|HTTP metrics| API["DevExTelemetry API<br/>Docker container"] |
| 130 | + API --> SQLITE[("SQLite DB file<br/>mounted volume")] |
| 131 | +``` |
| 132 | + |
| 133 | +### Example `docker-compose.yml` |
| 134 | + |
| 135 | +```yaml |
| 136 | +services: |
| 137 | + app: |
| 138 | + image: agoda/devex-telemetry:latest |
| 139 | + ports: |
| 140 | + - "8080:8080" |
| 141 | + volumes: |
| 142 | + - telemetry-data:/app/data |
| 143 | +
|
| 144 | +volumes: |
| 145 | + telemetry-data: |
| 146 | +``` |
| 147 | + |
| 148 | +### Pros |
| 149 | +- Simplest possible deployment |
| 150 | +- No separate database service required |
| 151 | + |
| 152 | +### Cons |
| 153 | +- Not suitable for multi-instance scaling |
| 154 | +- Lower durability/performance characteristics vs managed PostgreSQL |
| 155 | + |
| 156 | + |
| 157 | +## Pointing Clients at Your Deployment |
| 158 | + |
| 159 | +Compilation/test clients route as follows: |
| 160 | + |
| 161 | +1. If `DEVFEEDBACK_URL` is set, use it. |
| 162 | +2. Otherwise, use default `http://compilation-metrics`. |
| 163 | + |
| 164 | +### Preferred enterprise pattern: DNS default host |
| 165 | + |
| 166 | +Most corporate networks already use internal DNS for service discovery (for internal APIs, proxies, package mirrors, etc.). |
| 167 | + |
| 168 | +Because clients default to `http://compilation-metrics`, your network/workstation team can create an internal DNS record for `compilation-metrics` pointing to your telemetry API endpoint (ingress/internal LB/service host). |
| 169 | + |
| 170 | +Example (corporate internal DNS): |
| 171 | +- You may already have internal domains like `yourcompany.local`. |
| 172 | +- Teams might already access internal systems such as `sql01.yourcompany.local`. |
| 173 | +- Add a DNS record like `compilation-metrics.yourcompany.local` (or a short host alias `compilation-metrics`) and map it to your telemetry endpoint. |
| 174 | +- Once that DNS path exists, the default client URL can resolve and telemetry will flow with zero local setup. |
| 175 | + |
| 176 | +Once this is in place: |
| 177 | + |
| 178 | +- no per-developer setup is required, |
| 179 | +- telemetry works out-of-the-box, |
| 180 | +- rollout and changes stay centralized with infra/network teams. |
| 181 | + |
| 182 | +If you don’t control DNS yet, use `DEVFEEDBACK_URL` as a temporary bridge. |
| 183 | + |
| 184 | +### Workstation override (optional) |
| 185 | + |
| 186 | +```bash |
| 187 | +export DEVFEEDBACK_URL='https://your-devex-telemetry.example.com' |
| 188 | +``` |
| 189 | + |
| 190 | +Your IT support team can also push this centrally with endpoint/device management tooling if needed. |
| 191 | + |
| 192 | +--- |
| 193 | + |
| 194 | +## Security notes |
| 195 | + |
| 196 | +- Keep the API internal (VPN/private network/internal ingress). |
| 197 | +- Do not expose PostgreSQL directly to the public internet. |
| 198 | +- Use TLS for cross-network telemetry traffic. |
| 199 | +- Prefer secrets management (K8s secrets / vault / parameter store) over plaintext credentials in Helm values. |
0 commit comments