Commit Graph

43 Commits

Author SHA1 Message Date
Stefan Prodan 4949c9ff34
Disable image policy caching
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-02-09 11:49:27 +02:00
Sunny 4be070b871 Disable caching of Secrets and ConfigMaps
Disable caching of Secrets and ConfigMaps by default. Enable caching
using feature gate.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-01-30 21:22:23 +05:30
Paulo Gomes 7a05f4856c
libgit2: Remove references to libgit2 from code
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-12-09 11:30:55 +00:00
Paulo Gomes 0191d6b4cc
gogit: Add new ForceGoGitImplementation FeatureGate
ForceGoGitImplementation ignores the value set for gitImplementation
and ensures that go-git is used for all GitRepository objects.
This can be used to confirm that Flux instances won't break if/when
the libgit2 implementation was to be deprecated.

When enabled, libgit2 won't be initialized, nor will any git2go cgo
code be called.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-11-04 11:16:26 +00:00
Sanskar Jaiswal 0296f7acf0
refactor reconciler to use fluxcd/pkg/git
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2022-10-27 14:42:13 +01:00
Paulo Gomes 06f4acd118
Use helper.Metrics for recording metrics
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-09-05 14:03:08 +01:00
Paulo Gomes 0fdcf7fe6d
Enable RecoverPanic
The controller-runtime provides the ability to recover from
panics that have arisen from a reconciliation. This change
enables this functionality by default.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-08-10 09:59:19 +01:00
Paulo Gomes 4a8ddfad49
git: Decommission libgit2 Unmanaged Transport
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-08-09 13:47:48 +01:00
Paulo Gomes ec89ad41b9
Update source-controller to v0.25.7
This version of source-controller introduces a fix for the
SSH connections leak issue reported at:
https://github.com/fluxcd/image-automation-controller/issues/334

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-06-22 15:55:50 +05:30
Paulo Gomes d46a42e198
Add new flag --ssh-hostkey-algos
The new flag allow users to set the list of hostkey algorithms
to use for ssh connections, enabling them to ensure specific
are/aren't used.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-06-12 10:44:02 +01:00
Paulo Gomes 31fe65346a
git: Enable managed transport by default
GitManagedTransport enables the use of Managed Transport. This replaces
the previous 'EXPERIMENTAL_GIT_TRANSPORT' environment variable that was
used for the same result. This commit also enables it by default.

This is an opt-out feature, which can be disabled by starting the
controller with the argument '--feature-gates=GitManagedTransport=false'.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-06-01 21:03:54 +03:00
Sanskar Jaiswal dfa62d22e9 add flag to allow configuration of ssh kex algos
Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
2022-04-14 04:05:18 +05:30
Paulo Gomes 4a53f9defa
Add flags to configure exponential back-off retry
Add two new flags to enable users to configure exponential
back-off for Flux objects. The default values are now
set to 750ms for minimum retry time, and 15min for max.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-04-12 13:01:36 +01:00
Paulo Gomes 859a6ca93a
Update source-controller to v0.22.4
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-03-28 15:22:19 +01:00
Paulo Gomes 5b15bb7f94
Implement Managed Transport for libgit2
libgit2 network operations are blocking and do not provide timeout nor context capabilities,
leading to several reports of the controllers hanging indefinitely.

By using managed transport, golang primitives such as http.Transport and net.Dial can be used
to ensure timeouts are enforced.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-03-21 15:19:00 +00:00
Sunny 146a86865c Use new standardized runtime and meta package
Signed-off-by: Sunny <darkowlzz@protonmail.com>
2022-03-21 12:45:55 +01:00
Somtochi Onyekwere 0ca01bd254 Add flag to disable cross-namespace referencing
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-01-28 08:32:21 +01:00
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