From 6cda0a9aaa3f138852f3b185cfb0fff058904d0b Mon Sep 17 00:00:00 2001 From: Yiannis Date: Wed, 19 Jan 2022 08:33:48 +0000 Subject: [PATCH] Update dev docs Signed-off-by: Yiannis --- DEVELOPMENT.md | 72 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 11 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 3391d4922..0bea0e6a7 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -4,14 +4,29 @@ > to find out about how to contribute to Flux and how to interact with the > Flux Development team. +## Installing required dependencies + +There are a number of dependencies required to be able to run the controller and its test suite locally: + +- [Install Go](https://golang.org/doc/install) +- [Install Kustomize](https://kubernetes-sigs.github.io/kustomize/installation/) +- [Install Docker](https://docs.docker.com/engine/install/) +- (Optional) [Install Kubebuilder](https://book.kubebuilder.io/quick-start.html#installation) + +In addition to the above, the following dependencies are also used by some of the `make` targets: + +- `controller-gen` (v0.7.0) +- `gen-crd-api-reference-docs` (v0.3.0) +- `setup-envtest` (latest) + +If any of the above dependencies are not present on your system, the first invocation of a `make` target that requires them will install them. + ## How to run the test suite Prerequisites: -* go >= 1.16 -* kubebuilder >= 2.3 -* kustomize >= 3.1 +* Go >= 1.17 -You can run the unit tests by simply doing +You can run the test suite by simply doing ```bash make test @@ -19,17 +34,13 @@ make test ## How to run the controller locally -Install flux on your test cluster: +Install the controller's CRDs on your test cluster: ```sh -flux install +make install ``` -Scale the in-cluster controller to zero: - -```sh -kubectl -n flux-system scale deployment/helm-controller --replicas=0 -``` +Note that `helm-controller` depends on [source-controller](https://github.com/fluxcd/source-controller) to acquire the Helm charts from Helm repositories. If `source-controller` is not running on your test cluster, you need to tell `helm-controller` where to find it. Port forward to source-controller artifacts server: @@ -43,8 +54,47 @@ Export the local address as `SOURCE_CONTROLLER_LOCALHOST`: export SOURCE_CONTROLLER_LOCALHOST=localhost:8080 ``` +Alternatively, if your test cluster is already running `source-controller` and `helm-controller`, you need to scale down the in-cluster `helm-controller`: + +``` +kubectl -n flux-system scale deployment/helm-controller --replicas=0 +``` + Run the controller locally: ```sh make run ``` + +## How to install the controller + +### Building the container image + +Set the name of the container image to be created from the source code. This will be used when building, pushing and referring to the image on YAML files: + +```sh +export IMG=registry-path/helm-controller:latest +``` + +Build the container image, tagging it as `$(IMG)`: + +```sh +make docker-build +``` + +Push the image into the repository: + +```sh +make docker-push +``` + +**Note**: `make docker-build` will build an image for the `amd64` architecture. + + +### Deploying into a cluster + +Deploy `helm-controller` into the cluster that is configured in the local kubeconfig file (i.e. `~/.kube/config`): + +```sh +make deploy +``` \ No newline at end of file