Flagger Documentation
repository·main·Indexed 26 days ago
https://github.com/fluxcd/flaggerFlagger is a progressive delivery tool for Kubernetes that automates the release process by gradually shifting traffic to new software versions. It supports Canary releases, A/B testing, and Blue/Green mirroring, integrating with service meshes (Istio, Linkerd, AWS App Mesh, Kuma), ingress controllers (NGINX, Gloo, Contour, Traefik), and monitoring solutions like Prometheus to validate releases against metrics and tests.
What's inside Flagger
- Flagger is a progressive delivery tool for Kubernetes that automates the release process for applications. It reduces production risk by gradually shifting traffic to new software versions while simultaneously measuring metrics and running conformance tests. It supports deployment strategies such as Canary releases, A/B testing, and Blue/Green mirroring, and integrates with various ingress controllers, service meshes, and monitoring solutions.
Introduction to Flagger
mainFlagger is a progressive delivery Kubernetes operator that automates the release process for applications. It reduces production risk by gradually shifting traffic to new software versions while performing metric analysis and conformance testing.
Key Capabilities:
- Deployment Strategies: Supports Canary releases, A/B testing, and Blue/Green mirroring.
- Traffic Routing: Uses service meshes or ingress controllers to manage traffic shifts.
- Release Analysis: Integrates with Prometheus, InfluxDB, Datadog, New Relic, CloudWatch, Stackdriver, or Graphite.
- Alerting: Sends notifications via Slack, MS Teams, Discord, and Rocket.
- GitOps Integration: Declarative configuration via Kubernetes Custom Resources, making it compatible with GitOps tools like Flux CD.
Supported Deployment Strategies
mainFlagger supports several automated deployment strategies for application analysis, promotion, and rollback:
- Canary Release (progressive traffic shifting): Supported by Istio, Linkerd, App Mesh, NGINX, Skipper, Contour, Gloo Edge, Traefik, Kuma, Gateway API, Apache APISIX, and Knative.
- A/B Testing (HTTP headers and cookies traffic routing): Supported by Istio, App Mesh, NGINX, Contour, Gloo Edge, and Gateway API.
- Blue/Green (traffic switching): Supported by Kubernetes CNI, Istio, Linkerd, App Mesh, NGINX, Contour, Gloo Edge, and Gateway API.
- Blue/Green Mirroring (traffic shadowing): Supported by Istio and Gateway API.
- Canary Release with Session Affinity (progressive traffic shifting combined with cookie-based routing): Supported by Istio and Gateway API.
Note: Canary releases and A/B testing require a Layer 7 traffic management solution (service mesh or ingress controller). Blue/Green deployments do not require a service mesh or ingress controller.
Supported Deployment Strategies in Flagger
mainFlagger supports the following deployment strategies:
- Canary Release: Progressive traffic shifting to a new version.
- A/B Testing: Useful for frontend applications requiring session affinity via HTTP headers or cookie match conditions.
- Blue/Green: Switching traffic between two identical environments.
- Blue/Green Mirroring: A variation of Blue/Green where traffic is copied to the canary service. Note: Mirroring should only be used for idempotent requests that can be processed twice.
Uninstall Flagger Grafana
mainTo remove the
flagger-grafanadeployment, delete the Helm release. This command removes all associated Kubernetes components.helm delete --purge flagger-grafanaUninstall the Podinfo Helm Chart
mainTo remove the
frontenddeployment and all associated Kubernetes components, use thehelm deletecommand with the--purgeflag:helm delete --purge frontendhelm delete --purge frontendInstall Flagger using Kustomize
mainAs an alternative to Helm, Flagger can be installed using Kustomize.
Prerequisites
- Kubernetes cluster >=1.13.0
- Kustomize >=3.6.0
Run Flagger integration tests with Kind
mainFlagger provides end-to-end (e2e) integration tests that can be run locally using Kubernetes Kind.
Steps:
- Create a Kind cluster.
- Build the Flagger image and load it into the Kind cluster.
- Execute the e2e test script for your specific service mesh or ingress controller (e.g.,
./test/istio/run.sh).
# Create cluster kind create cluster # Build and load image make build docker build -t test/flagger:latest . kind load docker-image test/flagger:latest # Run Istio e2e tests ./test/istio/run.shInstall Gloo Edge and Flagger for Canary Deployments
mainTo use Flagger with Gloo Edge, you must first install Gloo Edge and then install Flagger with the
gloomesh provider and Prometheus enabled.Prerequisites:
- Kubernetes v1.16 or newer
- Gloo Edge 1.6.0 or newer
- Flagger 1.6.0 or newer
Installation Steps:
- Install Gloo using Helm.
- Install Flagger in the same namespace as Gloo, ensuring
meshProvideris set toglooandprometheus.installis set totrue.
# Install Gloo helm repo add gloo https://storage.googleapis.com/solo-public-helm kubectl create ns gloo-system helm upgrade -i gloo gloo/gloo --namespace gloo-system # Install Flagger with Gloo provider helm repo add flagger https://flagger.app helm upgrade -i flagger flagger/flagger \ --namespace gloo-system \ --set prometheus.install=true \ --set meshProvider=glooInstall Flagger with Istio
mainTo use Flagger with Istio, ensure you have Kubernetes v1.16+ and Istio v1.5+.
- Install Istio with the default profile:
istioctl manifest install --set profile=default- Install Prometheus (replace
release-1.18with your actual Istio version):
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.18/samples/addons/prometheus.yaml- Install Flagger into the
istio-systemnamespace:
kubectl apply -k github.com/fluxcd/flagger//kustomize/istioistioctl manifest install --set profile=default # Suggestion: Please change release-1.18 in below command, to your real istio version. kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.18/samples/addons/prometheus.yaml kubectl apply -k github.com/fluxcd/flagger//kustomize/istioImplement Graceful shutdown with preStop hooks
mainWhen a pod is terminated, Kubernetes sends a
SIGTERM. If the app doesn't handle this or exits too quickly, in-flight requests will fail.To allow the service mesh to drain traffic and remove the pod from Envoy sidecars before the app becomes unavailable, add a
preStophook to delay the container shutdown.apiVersion: apps/v1 kind: Deployment spec: template: spec: terminationGracePeriodSeconds: 60 containers: - name: app lifecycle: preStop: exec: command: - sleep - "10"Tutorial: Canary analysis with KEDA ScaledObjects
mainFollow this tutorial to perform canary analysis using KEDA ScaledObjects.