Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: extend development documentation #505

Merged
merged 1 commit into from
Dec 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 80 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,90 @@ $ LIBGIT2_FORCE=1 make libgit2
```

**Note:** Example shown is for Arch Linux, but likewise procedure can be
followed using any other package manager, e.g. `apt`.
followed using any other package manager. Some distributions may have slight
variation of package names (e.g. `apt install -y cmake openssl libssh2-1-dev`).

## How to run the test suite

You can run the unit tests by simply doing
The test suite depends on [envtest] being installed. For minimum required
version refer to the variable `ENVTEST_BIN_VERSION` in the [Makefile](./Makefile).

You can run the unit tests by simply doing:

```bash
make test
```

[envtest]: https://book.kubebuilder.io/reference/envtest.html#installation


## How to run the controller locally

Install flux on your test cluster:

```sh
flux install
```

Scale the in-cluster controller to zero:

```sh
kubectl -n flux-system scale deployment/source-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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative shorter way of the below multi-step instruction is the following:

$ IMG=container-registry.com/yourhandle/source-controller TAG=latest BUILD_ARGS=--push \
make docker-build

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, I added this as well as the longer version.

export IMG=registry-path/source-controller
export TAG=latest # optional
```

Build the container image, tagging it as `$(IMG):$(TAG)`:

```sh
make docker-build
```

Push the image into the repository:

```sh
make docker-push
```

Alternatively, the three steps above can be done in a single line:

```sh
IMG=registry-path/source-controller TAG=latest BUILD_ARGS=--push \
make docker-build
```
For an extensive list of `BUILD_ARGS`, refer to the docker [buildx build options] documentation.

**Note:** `make docker-build` will build images for all supported architecture by default.
Limit this to a specific architecture for faster builds:

```sh
IMG=registry-path/source-controller TAG=latest BUILD_ARGS=--push BUILD_PLATFORMS=amd64 \
make docker-build
```

[buildx build options]: https://docs.docker.com/engine/reference/commandline/buildx_build/#options


### Deploying into a cluster

Deploy `source-controller` into the cluster that is configured in the local kubeconfig file (i.e. `~/.kube/config`):

```sh
make dev-deploy
```