A collection of Python/Flask demos using Flipt feature flags.
A Flask app that toggles between light and dark themes based on a dark_mode boolean flag evaluated via the Flipt HTTP API.
# 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.pyImportant: You must set the
FLIPT_URLenvironment variable to point at your Flipt instance.FLIPT_URL=http://localhost:8080works for local development (the default in the code is a placeholder).
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.
# 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 0Adjust 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- Kubernetes cluster with Traefik (e.g. K3d)
kubectlconfigured for the target cluster- Docker