|
| 1 | +# FlowProxy: Client Deployment & Integration Guide |
| 2 | + |
| 3 | +This guide outlines exactly how to deploy FlowProxy into a client's existing infrastructure, whether they are running a simple monolithic application on a VPS or a complex microservice architecture on Kubernetes. |
| 4 | + |
| 5 | +As a consultant, your job is to seamlessly drop FlowProxy in front of their traffic without disrupting their existing applications. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Phase 1: Architecture Assessment |
| 10 | + |
| 11 | +Before writing any deployment manifests, determine how the client currently hosts their application: |
| 12 | + |
| 13 | +1. **The Startup/Agency Model (Docker Compose / Single VM)** |
| 14 | + - They have a single large server running multiple containers. |
| 15 | + - **Strategy:** Deploy FlowProxy on the same machine. Update DNS to point to FlowProxy, and route traffic to the internal Docker network. |
| 16 | + |
| 17 | +2. **The Enterprise Model (Kubernetes / Managed Cloud)** |
| 18 | + - They use EKS/GKE, have dozens of microservices, and currently use an AWS Application Load Balancer (ALB) or Nginx Ingress. |
| 19 | + - **Strategy:** Deploy FlowProxy as the "Edge API Gateway" or an Ingress Controller replacement inside their cluster. |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Phase 2: Deploying to Kubernetes (Microservices) |
| 24 | + |
| 25 | +When a client has multiple microservices (e.g., `user-service`, `payment-service`), FlowProxy acts as the central router and protector. |
| 26 | + |
| 27 | +### 1. The Traffic Flow |
| 28 | +Instead of exposing every microservice to the internet, you expose *only* FlowProxy. |
| 29 | +`Internet -> Cloud Load Balancer (ALB) -> FlowProxy -> Internal Microservices` |
| 30 | + |
| 31 | +### 2. Externalizing State (Crucial for K8s) |
| 32 | +In Kubernetes, pods are ephemeral. You **cannot** run Postgres and Redis inside the FlowProxy pod. |
| 33 | +* **Redis:** Connect FlowProxy to the client's managed Redis (e.g., AWS ElastiCache). This allows you to run 5+ replicas of FlowProxy that all share the exact same rate-limiting state. |
| 34 | +* **Postgres:** Connect FlowProxy to a managed Postgres instance (e.g., AWS RDS) so configuration and logs are safely stored outside the cluster. |
| 35 | + |
| 36 | +### 3. Kubernetes Deployment Manifests (Example) |
| 37 | +You will write standard K8s YAMLs for the client. |
| 38 | + |
| 39 | +**Deployment (`flowproxy-deployment.yaml`):** |
| 40 | +```yaml |
| 41 | +apiVersion: apps/v1 |
| 42 | +kind: Deployment |
| 43 | +metadata: |
| 44 | + name: flowproxy |
| 45 | +spec: |
| 46 | + replicas: 3 # Scale easily! |
| 47 | + selector: |
| 48 | + matchLabels: |
| 49 | + app: flowproxy |
| 50 | + template: |
| 51 | + metadata: |
| 52 | + labels: |
| 53 | + app: flowproxy |
| 54 | + spec: |
| 55 | + containers: |
| 56 | + - name: proxy |
| 57 | + image: shantkhatri/flowproxy:latest |
| 58 | + ports: |
| 59 | + - containerPort: 8080 |
| 60 | + env: |
| 61 | + # Instead of an external URL, point to the internal K8s DNS! |
| 62 | + - name: UPSTREAM_URL |
| 63 | + value: "http://internal-ingress-nginx.default.svc.cluster.local" |
| 64 | + - name: REDIS_ADDR |
| 65 | + value: "prod-redis.client.local:6379" |
| 66 | + - name: POSTGRES_DSN |
| 67 | + valueFrom: |
| 68 | + secretKeyRef: |
| 69 | + name: db-secrets |
| 70 | + key: dsn |
| 71 | +``` |
| 72 | +
|
| 73 | +**Service (`flowproxy-svc.yaml`):** |
| 74 | +```yaml |
| 75 | +apiVersion: v1 |
| 76 | +kind: Service |
| 77 | +metadata: |
| 78 | + name: flowproxy-service |
| 79 | +spec: |
| 80 | + type: LoadBalancer # Exposes FlowProxy to the internet |
| 81 | + ports: |
| 82 | + - port: 80 |
| 83 | + targetPort: 8080 |
| 84 | + selector: |
| 85 | + app: flowproxy |
| 86 | +``` |
| 87 | + |
| 88 | +### 4. Routing to Multiple Microservices |
| 89 | +FlowProxy currently uses a single `UPSTREAM_URL`. If the client has 20 microservices, you have two options: |
| 90 | +1. **The "Gateway" Approach:** Point FlowProxy's `UPSTREAM_URL` to an internal Nginx or K8s Service that handles the sub-routing. FlowProxy handles the rate-limiting and logging, then passes the scrubbed traffic to the internal router. |
| 91 | +2. **The "Custom Dev" Upsell:** Tell the client: *"I will modify FlowProxy's Go code so the `routes` table in Postgres directly maps `path_prefix` to different upstream URLs."* (This is a great freelance upsell). |
| 92 | + |
| 93 | +--- |
| 94 | + |
| 95 | +## Phase 3: Deploying for Docker Compose (Agencies / SMBs) |
| 96 | + |
| 97 | +If the client just has a few Docker containers on a DigitalOcean droplet: |
| 98 | + |
| 99 | +1. Copy your existing `docker-compose.yml`. |
| 100 | +2. Connect FlowProxy to the client's existing Docker network. |
| 101 | +3. Change the `UPSTREAM_URL` in `.env` to the internal container name of their app (e.g., `UPSTREAM_URL=http://their-app-container:3000`). |
| 102 | +4. Run `docker compose up -d`. FlowProxy now owns port `80` or `443` on their server. |
| 103 | + |
| 104 | +--- |
| 105 | + |
| 106 | +## Phase 4: Integrating Observability |
| 107 | + |
| 108 | +Enterprise clients already have observability stacks. They won't want to use a standalone Grafana container. |
| 109 | + |
| 110 | +### 1. Prometheus / Datadog Integration |
| 111 | +FlowProxy exposes standard Prometheus metrics at `:8080/metrics`. |
| 112 | +* **If they use Prometheus in Kubernetes:** Add Prometheus annotations to the FlowProxy deployment so their cluster automatically scrapes your proxy: |
| 113 | + ```yaml |
| 114 | + metadata: |
| 115 | + annotations: |
| 116 | + prometheus.io/scrape: "true" |
| 117 | + prometheus.io/port: "8080" |
| 118 | + prometheus.io/path: "/metrics" |
| 119 | + ``` |
| 120 | +* **If they use Datadog:** The Datadog agent can be configured with an OpenMetrics integration to scrape FlowProxy's `/metrics` endpoint natively. |
| 121 | + |
| 122 | +### 2. Exporting the Dashboard |
| 123 | +Export your "Blood Red / Critical" Grafana dashboard as a JSON file. Import this file directly into the client's central Grafana instance. |
| 124 | + |
| 125 | +--- |
| 126 | + |
| 127 | +## Phase 5: The Client Handover |
| 128 | + |
| 129 | +When you finish the freelance gig, provide the client with: |
| 130 | +1. **Admin Guide:** How to update the `routes` table in Postgres to adjust rate limits dynamically. |
| 131 | +2. **Alerting Handoff:** Ensure the `ALERT_SLACK_WEBHOOK` is pointing to their engineering team's Slack channel, not yours. |
| 132 | +3. **Scaling Instructions:** Explain that because Redis handles the sliding window, they can increase the Kubernetes replicas from 3 to 30 during a Black Friday spike, and the rate limiting will remain perfectly accurate across all nodes. |
0 commit comments