Skip to content

jmboby/flipt-testapp

Repository files navigation

flipt-testapp

A collection of Python/Flask demos using Flipt feature flags.


App 1: Dark Mode Dashboard

A Flask app that toggles between light and dark themes based on a dark_mode boolean flag evaluated via the Flipt HTTP API.

Getting Started

# Start Flipt
docker compose up -d

# Install dependencies
pip install -r requirements.txt

# Create the dark_mode flag in Flipt (run once)
python setup_flag.py

# Run the app (http://localhost:5001)
python app.py

Important: You must set the FLIPT_URL environment variable to point at your Flipt instance. FLIPT_URL=http://localhost:8080 works for local development (the default in the code is a placeholder).


App 2: Canary Traffic Routing (canary-routing/)

Uses Flipt's rollout percentage to control live HTTP traffic splitting between two app versions via Traefik weighted services on Kubernetes.

A sync controller polls Flipt every 10 seconds, reads the canary_rollout flag's threshold percentage, and patches the TraefikService weights to match.

Quick Start

# Build images
docker build -t canary-demo:latest ./canary-routing/app/
docker build -t sync-controller:latest ./canary-routing/scripts/

# Deploy to Kubernetes
kubectl apply -f canary-routing/k8s/

# Create the Flipt flag (0% = all traffic to v1)
kubectl port-forward svc/flipt 8080:8080 &
python canary-routing/scripts/setup_flag.py 0

Adjust traffic split via the Flipt UI or the setup script:

python canary-routing/scripts/setup_flag.py 50   # 50/50 split
python canary-routing/scripts/setup_flag.py 100  # all traffic to v2
python canary-routing/scripts/setup_flag.py 0    # rollback

Prerequisites

  • Kubernetes cluster with Traefik (e.g. K3d)
  • kubectl configured for the target cluster
  • Docker

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors