Commit Graph

26 Commits

Author SHA1 Message Date
Michael Bridgen fd52463ac5 Use v1beta1 of the API from image reflector
This bumps the version of the image reflector types to v1beta1. This
doesn't technically make a difference for the minute, since the
Kubernetes API server would convert between versions, but is tidier.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-28 13:59:34 +01:00
Michael Bridgen 5b9631327f Graduate v1alpha2 API to v1beta1
This does the following:

 - copies the type definitions from v1alpha2 to v1beta1
 - changes the "stored" version to v1beta1
 - gives the CRD a conversion strategy of None, meaning just rewrite the version
 - switches the controller to use v1beta1
 - moves the generated documentation to v1beta1

This effectively rebadges the v1alpha2 version of this part of the
image API to v1beta1. The v1alpha2 version is left in place; there are
no conversion issues, as with v1alpha1->v1alpha2. The CRD specifies
that converting between v1alpha2 and v1beta1 just means changing the
version (i.e., the schema and semantics are the same).

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-06-28 11:26:59 +01:00
Max Jonas Werner 93782755ef
feat: add controller concurrency
The controller is now working with 4 concurrent workers by default.
This value is configurable through the `--concurrent` flag.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2021-06-24 20:15:00 +02:00
Stefan Prodan 833b50fdee
Move to ImagePolicy v1alpha2
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-04-22 10:03:22 +03:00
Michael Bridgen cd8a2e97b8 Flip the controller and tests to API v1alpha2
This finishes the v1alpha2 API, and rewrites everything needed so that
the controller supports it and the tests pass. For the most part, that
is just changing the location of fields. However, there's a few
notable extras:

 - check that the `sourceRef` is a git repo (that's the default), and
   that a `.spec.git` is supplied;

 - change a test that blindly patched an update object, so that it
   first gets the object it's patching. Previously, it succeeded
   because it was OK to patch everything to empty strings, but that's
   no longer the case since SourceReference.Kind is an enum.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-04-13 10:45:58 +01:00
Michael Bridgen f28a0c40ff Add v1alpha2 API version
This adds a v1alpha2 API, without changing the controller or tests to
use it (yet). The new API has roughly the desired shape, per
https://github.com/fluxcd/flux2/discussions/1124, but supporting only
things that the controller supports now.

It's necessary to give the v1alpha1 type a `storageversion` marker so
that 1. code generation keeps working, and 2. tests still work, since
they still expect v1alphav1 types. v1alpha1 will be removed once the
controller and tests are ported to v1alpha2.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-04-13 10:30:51 +01:00
Stefan Prodan 299d874b9e
Use controller name in LeaderElectionID
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-25 14:22:02 +02:00
Stefan Prodan cdd4cb03f6
Set leader election deadline to 30s
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-25 14:04:15 +02:00
Hidde Beydals 3ee2f904e1 Enable pprof endpoints on metrics server
Using the helper from `pkg/runtime/pprof`, which follows the suggestion
from controller-runtime to use `AddMetricsExtraHandler`.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-02-07 12:52:14 +01:00
Stefan Prodan f5a8b922b9
Update fluxcd/pkg/runtime to v0.8.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-01-21 19:57:12 +02:00
Hidde Beydals 0531deaaed Upgrade controller-runtime to v0.7.0
This commit upgrades the `controller-runtime` dependency to `v0.7.0`,
including all changes required to make all wiring work again.

- Upgrade `runtime` to v0.6.2 to include `controller-runtime` changes.
- Logger has been removed from the reconciler, and is now retrieved
  from the `context.Context` passed to the `Reconcile` method and
  downwards functions.
- Logger configuration flags are now bound to the flag set using
  `BindFlags` from `runtime/logger`, ensuring the same contract across
  GitOps Toolkit controllers, and the `--log-json` flag has been
  deprecated in favour of the `--log-encoding=json` default.
- The `ChangePredicate` from `runtime` has changed to a
  `ReconcileRequestedPredicate`, and is now chained with the
  `GenerationChangedPredicate` from `controller-runtime` using
  `predicate.Or`.
- Signatures that made use of `runtime.Object` have changed to
  `client.Object`, removing the requirement to e.g. call
  `runtime.Object#Object`.
- The `leader-election-role` was changed, as leader election now works
  via the `coordination/v1` API.

Other notable changes:

- Upgrade of `image-reflector-controller` API package to include
  controller-runtime changes.
- Upgrade of `source-controller` API package to v0.6.1.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-01-14 13:48:37 +01:00
Michael Bridgen 64177cc6f5 Send notifications too when emitting events
This adds the external event recorder (a.k.a., notifications client)
to the reconciler, and expands the definition of
`<reconciler>.event(...)` so that it will send a notification whenever
an event is emitted. This is the conventional way of handling events
amongst the GitOps Toolkit controllers.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-12-01 11:37:23 +00:00
Michael Bridgen 31f1e62cd4 Use probes installer from fluxcd/pkg
Signed-off-by: Michael Bridgen <michael@weave.works>
2020-12-01 11:28:06 +00:00
Michael Bridgen 16e810a123 Record metrics for readiness and duration
Using the conventions of the day.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-12-01 11:08:29 +00:00
Michael Bridgen 311ca212c5 Give controller liveness and readiness endpoints
- make the healthz endpoint a flag and give the value to the
   controller runtime
 - set up probe endpoints; copy the func from elsewhere for now
 - add the probe defs to the deployment

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-23 13:44:12 +00:00
Michael Bridgen 5bd0bc8cba Set logger up with log level and JSON flags
This is the GitOps Toolkit convention.  This commit also puts the
flags in the base deployment config, in the same order as for other
GOTK controllers.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-23 12:54:15 +00:00
Michael Bridgen 59975f6ad0 Make room for event recorder
This gives the controller an event recorder, without using it yet, and
makes sure it is registered when setting everything up in main.go.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-23 11:23:30 +00:00
Michael Bridgen 385277bef3 Add --watch-all-namespaces flag to controller
This is a convention among the GitOps toolkit controllers; if false,
the controller will watch only resources in the namespace in which
it's running.

Signed-off-by: Michael Bridgen <michael@weave.works>
2020-11-23 11:08:05 +00:00
Hidde Beydals bf8c2deeb7 Make the API package a dedicated module
This includes changes to:

* Bump the Kubernetes dependencies to v1.19.3 to align
  with the other toolkit controllers.
* Update controller-runtime dependency to v0.6.3 to align
  with the other toolkit controllers.
* Update the source-controller dependency to the most recent
  v0.2.2 version to include the v1beta1 API.
* Add the `pkg/gittestserver` dependency for the Git tests,
  as this package was removed in a newer source-controller version.
* Bump the Go version to v1.15.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-11-19 12:16:17 +01:00
Hidde Beydals 29c60ecc6e Change copyright to Flux authors
Signed-off-by: Hidde Beydals <hello@hidde.co>
2020-10-27 17:57:31 +01:00
Michael Bridgen ab4a963d50 Change package name and fixup imports and paths 2020-08-10 18:09:57 +01:00
Michael Bridgen 48aac78343 Reassign copyright to Flux project 2020-08-10 17:48:24 +01:00
Michael Bridgen 739f3c1770 Add update strategy that uses image policy
Just to get points on the board, this gives ImageUpdateAutomation an
`update` field into which you can plug the name of an ImagePolicy
resource (from the image reflector controller). The idea is that the
automation will then replace the image in the policy, anywhere it's
used, with its latest version.
2020-07-23 18:20:35 +01:00
Michael Bridgen c5ae8f8812 Implement controller up to cloning the git repo
This is enough to clone the repo that's referenced in the
ImageUpdateAutomation resource. It reproduces a bunch of code from the
source-controller which is internal there, to avoid writing it from
scratch.
2020-07-23 18:20:35 +01:00
Michael Bridgen a048169819 Add ImageUpdateAutomation type and controller
kubebuilder create api --group image --version v1alpha1 \
      --kind ImageUpdateAutomation
2020-07-23 18:14:28 +01:00
Michael Bridgen baf50cd4fc Initialise controller scaffolding
go mod init github.com/squaremo/image-automation-controller
    kubebuilder init --domain=fluxcd.io
    $EDITOR hack/boilerplate.go.txt
2020-07-18 15:23:13 +01:00