Development Guide
This document describes how to build, test and run Flagger from source.
Setup dev environment
Flagger is written in Go and uses Go modules for dependency management.
On your dev machine install the following tools:
go >= 1.19
git >;= 2.20
bash >= 5.0
make >= 3.81
kubectl >= 1.22
kustomize >= 4.4
helm >= 3.0
docker >= 19.03
You'll also need a Kubernetes cluster for testing Flagger. You can use Minikube, Kind, Docker desktop or any remote cluster (AKS/EKS/GKE/etc) Kubernetes version 1.22 or newer.
To start contributing to Flagger, fork the repository on GitHub.
Create a dir inside your GOPATH
:
Clone your fork:
Set Flagger repository as upstream:
Sync your fork regularly to keep it up-to-date with upstream:
Build
Download Go modules:
Build Flagger binary:
Build load tester binary:
Code changes
We require all commits to be signed. By signing off with your signature, you certify that you wrote the patch or otherwise have the right to contribute the material by the rules of the DCO.
If your user.name
and user.email
are configured in your Git config, you can sign your commit automatically with:
Before submitting a PR, make sure your changes are covered by unit tests.
If you made changes to go.mod
run:
If you made changes to pkg/apis
regenerate Kubernetes client sets with:
Run code formatters:
Run unit tests:
API changes
If you made changes to pkg/apis
regenerate the Kubernetes client sets with:
Update the validation spec in artifacts/flagger/crd.yaml
and run:
Note that any change to the CRDs must be accompanied by an update to the Open API schema.
Manual testing
Install a service mesh and/or an ingress controller on your cluster and deploy Flagger using one of the install options listed here.
If you made changes to the CRDs, apply your local copy with:
Shutdown the Flagger instance installed on your cluster (replace the namespace with your mesh/ingress one):
Port forward to your Prometheus instance:
Run Flagger locally against your remote cluster by specifying a kubeconfig path:
Another option to manually test your changes is to build and push the image to your container registry:
Deploy your image on the cluster and scale up Flagger:
Now you can use one of the tutorials to manually test your changes.
Integration testing
Flagger end-to-end tests can be run locally with Kubernetes Kind.
Create a Kind cluster:
Build Flagger container image and load it on the cluster:
Run the Istio e2e tests:
For each service mesh and ingress controller, there is a dedicated e2e test suite, choose one that matches your changes from this list.
When you open a pull request on Flagger repo, the unit and integration tests will be run in CI.
Last updated