flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[DevOps] Zero-Downtime Blue-Green & Canary Deployment Infrastructure with Kubernetes & Helm

Open blurbeast opened this issue 2 months ago • 7 comments

Overview & Background

As FlowFi's transaction volume grows, deploying backend updates, indexer fixes, or database migrations cannot incur service disruptions or dropped WebSocket/SSE client streams. Production-grade high-availability infrastructure requires standardized Kubernetes manifests, Helm charts, and automated Blue-Green / Canary deployment pipelines with automated rollback capabilities.


Detailed Problem Statement

  1. Downtime During Deployments:
    • Simple rolling updates can terminate active long-polling SSE connections or interrupt in-flight indexer batch ingestion.
  2. Database Migration Desync:
    • Running Prisma migrations directly on startup can cause race conditions if multiple container replicas spin up simultaneously.
  3. Lack of Standardized Orchestration:
    • The repository currently relies on basic Dockerfiles and shell scripts, without enterprise-grade Helm charts for multi-cloud deployments (AWS EKS, GCP GKE, DigitalOcean).

Technical Specification & Architecture

1. Production Helm Chart (deploy/charts/flowfi/)

Structure:

deploy/charts/flowfi/
├── Chart.yaml
├── values.yaml
├── values-production.yaml
└── templates/
    ├── backend-deployment.yaml
    ├── indexer-statefulset.yaml
    ├── frontend-deployment.yaml
    ├── ingress.yaml
    ├── hpa.yaml
    ├── pdb.yaml
    └── migration-job.yaml

2. Architecture & Deployment Mechanics

  • Indexer Isolation: Run indexer as a singleton StatefulSet with readinessProbe checking ledger synchronization lag, preventing duplicate worker execution.
  • API Pods Blue-Green / Canary:
    • Deploy backend API pods with Horizontal Pod Autoscaler (HPA) targeting 70% CPU / Memory utilization.
    • Ingress controller (NGINX / Traefik / AWS ALB) manages weighted canary traffic splitting (e.g. 10% canary -> 100% stable).
  • Graceful Termination Handling:
    • Implement preStop hooks sending SIGTERM and allowing 30-second graceful drain for active SSE clients before pod eviction.
  • Pre-Upgrade Migration Job:
    • Execute Prisma database migrations in a dedicated Helm pre-upgrade hook job with advisory locking before launching new API pods.

3. Automated Rollback Trigger

  • ArgoCD / GitHub Actions monitors Prometheus error rates (flowfi_http_requests_total{status=~"5.."}). If 5xx error rate exceeds 1% during canary rollout, immediately abort and roll back.

Target Files

  • deploy/charts/flowfi/Chart.yaml
  • deploy/charts/flowfi/values.yaml
  • deploy/charts/flowfi/templates/backend-deployment.yaml
  • deploy/charts/flowfi/templates/indexer-statefulset.yaml
  • deploy/charts/flowfi/templates/migration-job.yaml
  • .github/workflows/deploy-canary.yml

Acceptance Criteria

  • [ ] Helm chart successfully renders templates and passes helm lint.
  • [ ] Pre-upgrade migration job runs to completion before new application pods are scheduled.
  • [ ] Backend pods gracefully drain active SSE connections on SIGTERM without abrupt connection termination.
  • [ ] Indexer runs strictly as a singleton to eliminate dual-indexer race conditions.
  • [ ] Documentation includes complete deployment guide for AWS EKS, GCP GKE, and local Minikube.

blurbeast avatar Sep 27 '26 05:09 blurbeast

@EneGab has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

Hi maintainer, please assign me this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @EneGab to this issue.

EneGab avatar Sep 27 '26 14:09 EneGab

@code-ony has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

I would love to work on this issue, please assign it to me

ℹ️ Repo Maintainers: To accept this application, review their application or assign @code-ony to this issue.

code-ony avatar Sep 27 '26 15:09 code-ony

Congratulations, @code-ony! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

🧑‍💻 @code-ony: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Sep 29 '26 17:09 drips-wave[bot]

@AkpakaProsper has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

I would love to work on this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @AkpakaProsper to this issue.

AkpakaProsper avatar Oct 15 '26 13:10 AkpakaProsper

@Hotmopo has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Hello maintainer, i would like to work on this issue

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Hotmopo to this issue.

Hotmopo avatar Oct 16 '26 22:10 Hotmopo

Congratulations, @Hotmopo! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

🧑‍💻 @Hotmopo: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Oct 16 '26 22:10 drips-wave[bot]

This issue has been completed by @Hotmopo as part of the Stellar Wave Program's 10th Wave 🥳

😎 @Hotmopo: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

drips-wave[bot] avatar Oct 18 '26 12:10 drips-wave[bot]