Spaces:
Runtime error
Runtime error
File size: 18,519 Bytes
73ba4f5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | # π Enterprise Deployment Guide: From Single-Node On-Premises to Multi-Node Mesh
This comprehensive guide details the production deployment models for the **Collaborative Fraud Intelligence (CFI)** platform:
1. **Part 1: One-Click Enterprise On-Premises Production Stack (`docker-compose.yml`)** β The unified production stack hosting the security gateway, frontend SPA, backend API, PostgreSQL 16, and Redis 7.2 with optional OpenTelemetry, Prometheus, and Grafana monitoring profiles.
2. **Part 2: Multi-Node Network-Isolated Distributed Cluster (`docker-compose.multinode.yml`)** β The multi-container distributed topology enforcing strict subnet isolation across distinct bank institutions.
3. **Part 3: Enterprise Kubernetes & GitOps Helm Mesh (`deployments/helm/cfi-platform`)** β Production Kubernetes microservices deployment with automated NetworkPolicies, HPAs, PodDisruptionBudgets, and ArgoCD synchronization.
4. **Part 4: Post-Deployment Smoke Testing & Automated Verification** β CLI tools and test suites ensuring 100% deployment integrity.
> [!NOTE]
> For cloud infrastructure topologies, Terraform manifests, and disaster recovery failover architectures, refer to [`docs/production_infrastructure.md`](production_infrastructure.md) and [`docs/disaster_recovery_plan.md`](disaster_recovery_plan.md). For interactive API exploration, see [`docs/developer_and_api_portal.md`](developer_and_api_portal.md).
---
# Part 1: One-Click Enterprise On-Premises Stack (`docker-compose.yml`)
## 1.1 Architectural Topology
```
[ Bank Network / Corporate Browser / Core Banking ESB ]
β
βΌ (Port 80 / 443)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. Enterprise Nginx Gateway (`cfi-gateway`) β
β β’ Same-Origin Routing: eliminates browser CORS β
β β’ WebSocket Keepalive: 86400s timeout on /ws/* β
β β’ Hardened Headers: HSTS, CSP, X-Frame-Options β
ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββ΄βββββββββββββββββ
βΌ (/ and /assets/*) βΌ (/api/* and /ws/*)
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β 2. Frontend Web Container β β 3. Backend API & Engine β
β (`cfi-frontend`) β β (`cfi-api-server`) β
β β’ Multi-stage Alpine β β β’ Python 3.12, Uvicorn β
β β’ HTML5 pushstate SPA β β β’ Non-root user (1000) β
βββββββββββββββββββββββββββββ βββββββββββββββ¬ββββββββββββββ
β
ββββββββββββββββββββββββββ΄βββββββββββββββββββββββββ
βΌ (State / Relational) βΌ (Cache / Events)
βββββββββββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββ
β 4. PostgreSQL 16 Enterprise Database β β 5. Redis 7.2 Cache & Message Broker β
β (`cfi-postgres`) β β (`cfi-redis`) β
β β’ Idempotent init SQL (01-init.sql) β β β’ Protected mode auth, AOF persistence β
β β’ pg_isready healthcheck gating β β β’ Memory ceiling (512MB volatile-lru) β
βββββββββββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββββ
β β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββ
βΌ (Optional Enterprise & Monitoring Profiles)
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β 6. OpenTelemetry Collectorβ β 7. Prometheus v2.50.1 β β 8. Grafana OSS 10.3.3 β
β (`cfi-otel-collector`) β βββΊ β (`cfi-prometheus`) β βββΊ β (`cfi-grafana`) β
β β’ Ports 4317/4318/8889 β β β’ Port 9090 β β β’ Port 3000 β
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β 9. HashiCorp Vault 1.15 β β 10. MinIO Object Storage β β 11. MLflow Registry 2.11 β
β (`cfi-vault`) β β (`cfi-minio`) β β (`cfi-mlflow`) β
β β’ --profile enterprise β β β’ --profile storage β β β’ --profile ml β
β β’ Health: sys/health β β β’ Health: minio/live β β β’ Health: /health β
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
```
## 1.2 Step-by-Step Operator Instructions
### Step 1: Generate Cryptographically Secure Production Secrets
Run the platform secrets generator to populate `.env` with 256-bit random tokens:
```bash
python scripts/generate_secrets.py
```
This utility replaces default placeholders in `.env.example` with cryptographically random strings for `SECRET_KEY`, `POSTGRES_PASSWORD`, `REDIS_PASSWORD`, and `CONSORTIUM_HMAC_SALT`.
### Step 2: Pre-Flight Configuration Verification
Assert zero Compose syntax drift and verify service manifest integrity:
```bash
python scripts/verify_docker_deployment.py
```
The verification script checks:
- Existence of `docker-compose.yml`, `docker-compose.dev.yml`, `docker-compose.multinode.yml`, `Dockerfile.frontend`, `Dockerfile.backend`, and `01-init.sql`.
- Syntactic validity via `docker compose config`.
- Required environment variable floors and non-root security.
- Nginx security headers and long-lived WebSocket keepalive directives.
- Authenticated health probes across Redis, PostgreSQL, Gateway, Frontend, Backend, Vault, MinIO, and MLflow.
### Step 3: Launch Enterprise Stack
Spin up the 5 core production containers:
```bash
docker compose up -d --build
```
To include the OpenTelemetry, Prometheus, and Grafana monitoring stack:
```bash
docker compose --profile monitoring up -d --build
```
To launch with the full enterprise suite (Vault KMS, MinIO S3 storage, MLflow registry, and Monitoring):
```bash
docker compose --profile enterprise --profile storage --profile ml --profile monitoring up -d --build
```
### Step 4: Verify Live Service Health
Check container health statuses:
```bash
docker compose ps
```
All containers (`cfi-gateway`, `cfi-frontend`, `cfi-api-server`, `cfi-postgres`, `cfi-redis`) should transition to `healthy`.
---
# Part 2: Multi-Node Network-Isolated Deployment (`docker-compose.multinode.yml`)
## 2.1 Architecture Overview
```
Bank A Private Subnet (cfi-bank-a-private-net) Bank B Private Subnet (cfi-bank-b-private-net) Bank C Private Subnet (cfi-bank-c-private-net)
ββββββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββ
β cfi-bank-client-a β β cfi-bank-client-b β β cfi-bank-client-c β
β - Isolated DB Volume (bank-a-data) β β - Isolated DB Volume (bank-b-data) β β - Isolated DB Volume (bank-c-data) β
β - Bank A X.509 Cert (bank-a-pki) β β - Bank B X.509 Cert (bank-b-pki) β β - Bank C X.509 Cert (bank-c-pki) β
βββββββββββββββββββββββ¬βββββββββββββββββββββββ βββββββββββββββββββββββ¬βββββββββββββββββββββββ βββββββββββββββββββββββ¬βββββββββββββββββββββββ
β consortium-net only β consortium-net only β consortium-net only
ββββββββββββββββββββββββ ββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββββββββββββββββ
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β cfi-fl-coordinator β
β - Central PKI / CA (coord-pki) β
β - Secure Aggregator (FedAvg/Krum/TrimmedMean) β
β - gRPC Target: :50051 β
β - REST API Target: :8000 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
### Key Isolation Rules
- **No Direct Inter-Bank Routing**: `cfi-bank-client-a`, `cfi-bank-client-b`, and `cfi-bank-client-c` cannot reach each other directly. `bank-a-net`, `bank-b-net`, and `bank-c-net` are marked `internal: true`.
- **Outbound-Only Communication**: Bank client daemons initiate outbound mTLS connections to the central coordinator over `consortium-net` port 50051. Bank nodes expose no inbound listening ports to external entities.
- **Cryptographic Certificate Isolation**: Each participant container uses a dedicated X.509 mTLS certificate and private key stored in an isolated volume.
---
## 2.2 Step-by-Step Deployment Instructions
### Step 1: Provision Per-Node X.509 PKI Certificates
Generate separate mTLS certificate bundles for each node:
```bash
# Provision Coordinator PKI
python scripts/init_vault_pki.py --node-id coordinator --out-dir pki/coordinator
# Provision Bank A PKI
python scripts/init_vault_pki.py --node-id bank-a --out-dir pki/bank-a
# Provision Bank B PKI
python scripts/init_vault_pki.py --node-id bank-b --out-dir pki/bank-b
# Provision Bank C PKI
python scripts/init_vault_pki.py --node-id bank-c --out-dir pki/bank-c
```
Each directory contains:
- `cert.pem`: Node leaf certificate
- `key.pem`: Node RSA private key
- `ca.pem`: Consortium Root CA certificate
### Step 2: Validate Docker Compose Configuration
Verify multi-node compose configuration syntax:
```bash
docker compose -f docker-compose.multinode.yml config
```
### Step 3: Launch Multi-Node Stack
Start the coordinator and bank client containers:
```bash
docker compose -f docker-compose.multinode.yml up -d --build
```
### Step 4: Verify Container Status & Health
Check container statuses:
```bash
docker compose -f docker-compose.multinode.yml ps
```
Verify coordinator health endpoint:
```bash
curl -f http://localhost:8000/health
```
### Step 5: Verify Network Isolation Boundaries
Confirm that Bank A **cannot** communicate directly with Bank B:
```bash
# Expect failure / unreachable host (proving internal subnet isolation)
docker exec cfi-bank-client-a ping -c 2 cfi-bank-client-b
```
Verify that Bank A **can** reach the central coordinator over gRPC port 50051:
```bash
docker exec cfi-bank-client-a nc -zv coordinator 50051
```
---
# Part 3: Enterprise Kubernetes & GitOps Helm Mesh (`deployments/helm/cfi-platform`)
For enterprise cloud deployments on AWS EKS, GCP GKE, or Azure AKS, the platform provides a hardened Helm chart and ArgoCD GitOps application manifests.
## 3.1 Kubernetes Architecture & Resource Matrix
The Helm chart in [`deployments/helm/cfi-platform`](../deployments/helm/cfi-platform) deploys **16 validated Kubernetes resources**:
| Resource Category | Resource Name | Purpose |
| :--- | :--- | :--- |
| **NetworkPolicy** | `cfi-release-bank-node-isolation` | Restricts bank client pods to outbound-only egress towards coordinator |
| **NetworkPolicy** | `cfi-release-coordinator-ingress` | Gating ingress to coordinator on mTLS port 50051 and HTTP 8080 |
| **NetworkPolicy** | `cfi-release-default-deny-cross-namespace` | Enforces zero-trust cross-namespace tenant isolation |
| **PodDisruptionBudget** | `cfi-release-coordinator-pdb` | Ensures high-availability quorum during cluster node upgrades |
| **PodDisruptionBudget** | `cfi-release-fraud-alert-pdb` | Gating zero-downtime rolling updates for scoring service |
| **Service & Deployment** | `cfi-release-aggregator` | Byzantine-resilient federated model aggregation engine |
| **Service & Deployment** | `cfi-release-bank-node` | Containerized bank training daemon pods |
| **Deployment** | `cfi-release-coordinator` | Central federated coordinator and hyperparameter negotiation |
| **Deployment** | `cfi-release-fraud-alert` | Real-time payment transaction scoring and alert engine |
| **Deployment** | `cfi-release-identity-graph` | Privacy-preserving identity graph and MinHash LSH fuzzy resolver |
| **HPA** | `cfi-release-aggregator-hpa` | Horizontal Pod Autoscaler for aggregation worker pool |
| **HPA** | `cfi-release-coordinator-hpa` | Autoscaling coordinator based on participating bank load |
| **HPA** | `cfi-release-fraud-alert-hpa` | Autoscaling scoring service targeting 70% CPU threshold |
| **Ingress** | `cfi-release-ingress` | TLS termination and host-based routing for API and Web portals |
## 3.2 Kubernetes Dry-Run Manifest Validation
Validate all Helm templates and Kubernetes API contracts before cluster application:
```bash
# Validate core microservices chart (16 resources)
python scripts/validate_k8s_manifests.py
# Validate all repository Helm charts (39 total resources across microservices, GitOps, and standalone charts)
python scripts/validate_k8s_manifests.py --all
```
*Output: All 39 Kubernetes resources rendered and validated cleanly against Kubernetes API schemas.*
## 3.3 Helm Deployment Execution
```bash
helm upgrade --install cfi-release deployments/helm/cfi-platform \
--namespace cfi \
--create-namespace \
-f deployments/helm/cfi-platform/values.yaml
```
## 3.4 ArgoCD GitOps Continuous Deployment
Deploy via ArgoCD GitOps controller:
```bash
kubectl apply -f deployments/argocd/application.yaml -n argocd
```
---
# Part 4: Post-Deployment Smoke Testing & Diagnostics
Following any production deployment, execute the automated verification suite to validate end-to-end service reachability, SLA compliance, and documentation gateways:
```bash
python scripts/production_smoke_test.py --target-url http://localhost:80
```
The smoke test validates:
- **`GET /health`**: Health status and microservice readiness.
- **`GET /openapi.json`**: OpenAPI 3.1 schema completeness.
- **`GET /scalar`**: Interactive dark-themed Scalar documentation gateway.
- **`GET /docs`**: Standard Swagger UI interface.
- **`GET /api/v1/security/status`**: KMS encryption, mTLS, and ABAC policy state.
- **`POST /api/v1/predict`**: Sub-10ms risk scoring forward pass.
- **`GET /api/v1/diagnostics/connectors`**: Health probes across Kafka, Vault, KMS, Splunk, Redis, and Database.
---
# Part 5: π§ͺ Automated Test Suite Parity
The deployment configurations and infrastructure manifests are backed by automated tests:
```bash
python -m pytest \
backend/tests/unit/test_docker_manifests.py \
backend/tests/integration/test_multinode_fl_round.py -v
# 6 passed in 0.94s (100% Pass)
```
| Test Suite | Test Count | Scope |
| :--- | :---: | :--- |
| `test_docker_manifests.py` | 3 | Secrets generator entropy, 5 core services Compose structure, Nginx WebSocket & security headers |
| `test_multinode_fl_round.py` | 3 | Multi-node network isolation boundary, per-node mTLS PKI cert generation, daemon config |
| `verify_docker_deployment.py` | CLI | 100% audit pass across Dockerfiles, Compose manifests, env floor, and Nginx reverse proxy |
| `validate_k8s_manifests.py` | CLI | Dry-run schema validation of all 16 Kubernetes Helm resources |
|