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

Update dev docs #555

Merged
merged 1 commit into from
Jan 25, 2022
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
61 changes: 42 additions & 19 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,32 @@

## Installing required dependencies

The dependency [libgit2](https://libgit2.org/) needs to be installed to be able
to run source-controller or its test-suite locally (not in a container).
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)

The dependency [libgit2](https://libgit2.org/) also needs to be installed to be able
to run `source-controller` or its test-suite locally (not in a container).

In case this dependency is not present on your system (at the expected
version), the first invocation of a `make` target that requires the
dependency will attempt to compile it locally to `hack/libgit2`. For this build
to succeed; CMake, Docker, OpenSSL 1.1 and LibSSH2 must be present on the system.
to succeed ensure the following dependencies are present on your system:
- [CMake](https://cmake.org/download/)
- [OpenSSL 1.1](https://www.openssl.org/source/)
- [LibSSH2](https://www.libssh2.org/)
- [pkg-config](https://freedesktop.org/wiki/Software/pkg-config/)

Triggering a manual build of the dependency is possible as well by running
`make libgit2`. To enforce the build, for example if your system dependencies
match but are not linked in a compatible way, append `LIBGIT2_FORCE=1` to the
`make` command.

Follow the instructions below to install these dependencies to your system.

### macOS

```console
Expand All @@ -39,32 +52,31 @@ $ LIBGIT2_FORCE=1 make libgit2
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

The test suite depends on [envtest] being installed. For minimum required
version refer to the variable `ENVTEST_BIN_VERSION` in the [Makefile](./Makefile).
In addition to the above, the following dependencies are also used by some of the `make` targets:

You can run the unit tests by simply doing:
- `controller-gen` (v0.7.0)
- `gen-crd-api-reference-docs` (v0.3.0)
- `setup-envtest` (latest)

```bash
make test
```

[envtest]: https://book.kubebuilder.io/reference/envtest.html#installation
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

## How to run the controller locally
Prerequisites:
* Go >= 1.17

Install flux on your test cluster:
You can run the test suite by simply doing

```sh
flux install
make test
```

Scale the in-cluster controller to zero:
## How to run the controller locally

Install the controller's CRDs on your test cluster:

```sh
kubectl -n flux-system scale deployment/source-controller --replicas=0
make install
```

Run the controller locally:
Expand Down Expand Up @@ -115,11 +127,22 @@ IMG=registry-path/source-controller TAG=latest BUILD_ARGS=--push BUILD_PLATFORMS

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

If you get the following error when building the docker container:
```
Multiple platforms feature is currently not supported for docker driver.
Please switch to a different driver (eg. "docker buildx create --use")
```

you may need to create and switch to a new builder that supports multiple platforms:

```sh
docker buildx create --use
```

### 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
make deploy
```