Skip to content

Support blue/green deployments without a service mesh or ingress controller #209

@stefanprodan

Description

@stefanprodan

Flagger has all the logic in place to run blue/green deployments without the need for a service mesh or an ingress controller.

Blue/Green scenario:

  • on bootstrap, Flagger will create only the three ClusterIP services (app-primary, app-canary, app)
  • when a new version is detected, Flagger would scale up the new version and run the conformance tests (the test runner should target the app-canary ClusterIP service)
  • if the conformance tests are passing, Flagger would start the load tests and validate them with custom Prometheus queries (similar to how A/B testing works)
  • if the load test analysis is successful, Flagger would promote the new version to app-primary and app and scale down the canary version

A Blue/Green deployment could be defined as:

apiVersion: flagger.app/v1alpha3
kind: Canary
metadata:
  name: podinfo
spec:
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: podinfo
  service:
    port: 9898
  canaryAnalysis:
    interval: 1m
    threshold: 2
    iterations: 10
    metrics:
    - name: "5xx percentage"
      threshold: 5
      query: |
        100 - sum(
            rate(
                http_request_duration_seconds_count{
                  kubernetes_namespace="test",
                  kubernetes_pod_name=~"podinfo-[0-9a-zA-Z]+(-[0-9a-zA-Z]+)"
                  status!~"5.*"
                }[1m]
            )
        )
        /
        sum(
            rate(
                http_request_duration_seconds_count{
                  kubernetes_namespace="test",
                  kubernetes_pod_name=~"podinfo-[0-9a-zA-Z]+(-[0-9a-zA-Z]+)"
                }[1m]
            )
        ) * 100
    - name: "latency greater than 500 ms"
      threshold: 500
      interval: 1m
      query: |
        histogram_quantile(0.99,
          sum(
            rate(
              http_request_duration_seconds_bucket{
                kubernetes_namespace="test",
                kubernetes_pod_name=~"podinfo-[0-9a-zA-Z]+(-[0-9a-zA-Z]+)"
              }[1m]
            )
          ) by (le)
        )
    webhooks:
      - name: "acceptance tests"
        type: pre-rollout
        url: http://flagger-batstester.test/
        timeout: 5m
        metadata:
          type: "bash"
          cmd: "bats /tests/acceptance.bats"
      - name: load-test
        url: http://flagger-loadtester.test/
        timeout: 5s
        metadata:
          cmd: "hey -z 1m -q 10 -c 2 http://podinfo-canary.test:9898/"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions