Integration in CI/CD

Please make sure you've got the pre-requisites

Install a webhook into the existing

Flagger Webhook

If there's an existing Canary kind resource defined, you can add the following to webhook section:

    ...
    ...
    webhooks:
    - name: verify
      type: rollout
      url: https://api.hybridk8s.tech/api/flagger/verify
      timeout: 600s
      metadata:
        api_key: "<CLUSTER_KEY>"
        app: "<APP_NAME>"
        primary: "<DEPLOYMENT_NAME_OF_PRIMARY>"
        canary: "<DEPLOYMENT_NAME_OF_CANARY>"
        container: "<CONTAINER_NAME_IF_ANY>"
        duration: "<DURATION(seconds)_FOR_WHICH_LOGS_TO_BE_CONSIDERED>"

If there's no existing Canary kind resource defined, create a canary custom resource for app deployment.

Here's a template canary.yaml you can add (ideally in the helm chart directory). Just make sure to add your Cluster API Key, app name, namespace and other details in the canary.yaml before applying :

apiVersion: flagger.app/v1beta1
kind: Canary
metadata:
  name: <APP-NAME>
  namespace: <APP_NAMESPACE>
spec:
  # deployment reference
  targetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: test-app
  # the maximum time in seconds for the canary deployment
  # to make progress before it is rollback (default 600s)
  progressDeadlineSeconds: 800
  service:
    # ClusterIP port number
    port: 80
    # container port number or name (optional)
    targetPort: 8080
  analysis:
    # schedule interval (default 60s)
    interval: 60s
    # max number of failed metric checks before rollback
    threshold: 1
    # max traffic percentage routed to canary
    # percentage (0-100)
    maxWeight: 50
    # canary increment step
    # percentage (0-100)
    stepWeight: 5
    # Linkerd Prometheus checks
    webhooks:
    - name: load-test
      type: rollout
      url: http://flagger-loadtester.test/
      metadata:
        cmd: "hey -z 60m -q 100 -c 2 http://test-app.demo/test"
    - name: verify
      type: rollout
      url: https://api.hybridk8s.tech/api/flagger/verify
      timeout: 600s
      metadata:
        api_key: "<CLUSTER_KEY>"
        app: "<APP_NAME>"
        primary: "<DEPLOYMENT_NAME_OF_PRIMARY>"
        canary: "<DEPLOYMENT_NAME_OF_CANARY>"
        container: "<CONTAINER_NAME_IF_ANY>"
        duration: "<DURATION(seconds)_FOR_WHICH_LOGS_TO_BE_CONSIDERED>"

Now apply the canary to the cluster.

kubectl apply -f ./canary.yaml

Go grab a cup of coffee ☕️ ... it'll take a few minutes to brew the magic! ✨

API Webhook

You can also directly integrate webhook into existing CI/CD

curl --location --request
POST 'https://api.hybridk8s.tech/api/verify'
--header 'Content-Type: application/json'
--data-raw '{
        "api_key"   : <CLUSTER_API_KEY>,
        "app"       : <APP_NAME>,
        "namespace" : <APP_NAMESPACE>,
        "primary"   : <DEPLOYMENT_NAME_OF_PRIMARY>,
        "canary"    : <DEPLOYMENT_NAME_OF_CANARY>,
        "container" : <CONTAINER_NAME_IF_ANY>,
        "duration"  : <DURATION_IN_SECONDS_FOR_WHICH_LOGS_TO_BE_CONSIDERED>
}'

Argo Webhook

Coming soon...

results matching ""

    No results matching ""