Commit Graph

43 Commits

Author SHA1 Message Date
Sunny 84e1d74e32 Add alert and provider reconcilers for migration
Add new Alert and Provider reconcilers to perform migration to static
objects. The new Alert and Provider APIs don't contain any status. When
the existing Alerts and Providers are queries using the new API client,
the status would be dropped. A subsequent write of the object to update
the object in api-server will migrate the objects to the new version and
drop the status.
For the stale finalizers on the objects, the new reconcilers ensure that
the finalizers get removed.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Sunny 19a60e98ea event handler: Add k8s events for Alerts
Emit events in the event handler along with logs on the respective alert
to make the message visible on the alert it belongs to.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Sunny 36bc6529ae Remove Alert and Provider reconcilers
In v1beta3 API, Alert and Provider are static objects and don't need
reconcilers.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Sunny 4bf469e61b Add Alert and Provider v1beta3 API
v1beta3 API for Alert and Provider makes them static objects, removing
the status subresource and spec fields that are relevant to dynamic
objects with reconcilers.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Stefan Prodan 49d510de81
Update dependencies to Kubernetes v1.28
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-11-21 13:41:08 +02:00
Sunny 72c5b1fc6e Delete stale metrics on object delete
The metrics helper now accepts owned finalizers to determine if an
object is no longer managed by the controller and is being deleted, and
deletes the metrics associated with the object.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-08-15 02:37:58 +05:30
Stefan Prodan 963b3da8a7
Rename controllers to controller
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-05-24 10:58:18 +03:00
Sanskar Jaiswal 24b84e29b6
update deps and Kubernetes to 1.27.2
* github.com/fluxcd/pkg/apis/event => v0.5.0
* github.com/fluxcd/pkg/apis/meta => v1.1.0
* github.com/fluxcd/pkg/git => v0.12.1
* github.com/fluxcd/pkg/runtime => v0.37.0
* github.com/fluxcd/pkg/ssa => v0.28.0
* github.com/getsentry/sentry-go => v0.21.0
* github.com/ktrysmt/go-bitbucket => v0.9.58
* github.com/onsi/gomega => v1.27.7
* github.com/stretchr/testify => v1.8.3
* golang.org/x/oauth2 => v0.8.0
* k8s.io/api => v0.27.2
* k8s.io/apimachinery => v0.27.2
* k8s.io/client-go => v0.27.2
* sigs.k8s.io/controller-runtime => v0.15.0-beta.0

Changes made due to breaking changes in controller-runtime v0.15:

* Watches requires a plain `client.Object` instead of a `source.Kind` object.
* `handler.MapFunc` requires a Go context.
* `ctrl.Options.Namespace` was moved to `ctrlcache.Options.Namespaces`.
* `ctrl.Options.ClientDisableCacheFor` was moved to `ctrlclient.CacheOptions.DisableFor`.
* `ctrl.Options.Port` has been deprecated and removed.
* Use `MaxConcurrentReconciles` and `RecoverPanice` in `config.Controller` instead of `controller.Options`.

Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
2023-05-24 10:36:20 +03:00
Max Jonas Werner 0c0109a4bd
move all controllers to `internal` package
closes #499

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-03-30 15:53:04 +02:00
Max Jonas Werner ec03bd20a3
Introduce v1 API and bump Receiver version to v1
This commit bumps the Receiver API version to v1 in preparation of
the Flux GitOps GA milestone
(https://fluxcd.io/roadmap/#flux-gitops-ga-q1-2023).

We are now actively maintaining two versions of the notification API
group in parallel: v1 which currently only holds the Receiver kind and
v1beta2 for all other kinds.

Since we haven't run into this situation before, I had to change the
way we expose the API docs in ./docs/api: The directory now has
sub-directories for each active API version. Therefore we need to
change our scripts in the website repository to take this change into
account so that we expose both API group version at
https://fluxcd.io/flux/components/notification/api/. This change is
implemented in https://github.com/fluxcd/website/pull/1427.

refs #436

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-03-30 15:40:54 +02:00
Hidde Beydals fddd3d6fda
Use `logger.SetLogger` to also configure `klog`
This uses the newly introduced helper from runtime, which also
configures the logger for `klog`.

Resulting in all logs now being properly formatted, even when logged by
internal Kubernetes elements like the leader election or a dynamic
client.

The update from `fluxcd/pkg/runtime` from `v0.29.0` to `v0.31.0` in
addition includes a change which configures the event recoder to only
log on level `trace` (as opposed to `debug`).

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-03-08 10:17:08 +01:00
Hidde Beydals c90e58eca7 Disable caching of Secrets and ConfigMaps
You can re-enable caching by starting the controller with the argument
`--feature-gates=CacheSecretsAndConfigMaps=true`.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2023-01-30 15:10:56 +00:00
Stefan Prodan ee2600a07c Issue warning events on reconciliation errors
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-12-09 12:05:51 +00:00
Stefan Prodan 974a77da00 Refactor reconcilers and introduce v1beta2 API
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-12-09 11:03:53 +00:00
Paulo Gomes 78dcebeea0
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-08-09 17:49:57 +01:00
Stefan Prodan 44c08a2659
Allow disabling cross-namespace event sources
Introduce the flag `--no-cross-namespace-refs` (defaults to false) for allowing cluster admins to disable cross-namespace event sources for alerts.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-01-28 10:30:31 +02:00
Somtochi Onyekwere 19a0daa906 Use conditions helper in reconciler
Co-authored-by: Piaras Hoban <piaras@weave.works>
Co-authored-by: Hidde Beydals <hiddeco@users.noreply.github.com>
Co-authored-by: souleb <bah.soule@gmail.com>
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-11-01 14:20:12 +01:00
Philip Laine 42d364be14 Remove rate limiter from receiver
Signed-off-by: Philip Laine <philip.laine@xenit.se>
2021-04-01 10:50:29 +02:00
Philip Laine e58fc2c96c Add rate limiter to receiver and event http servers
Signed-off-by: Philip Laine <philip.laine@xenit.se>
2021-04-01 09:48:45 +02:00
Stefan Prodan a530be537e
Set leader election deadline to 30s
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-25 15:05:08 +02:00
Somtochi Onyekwere 9aba08e6bf Uses unstructured client to annotate object
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2021-03-04 08:01:53 +01:00
Hidde Beydals db475c969b 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:44:35 +01:00
Stefan Prodan dff79355ec
Update fluxcd/pkg/runtime to v0.8.0
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-01-22 10:23:47 +02:00
Stefan Prodan c148d6a036
Trigger ImageRepository reconciliation with webhook receivers
- Add ImageRepository to the Receiver API known kinds and RBAC
- Trigger container image updates to Git by annotating ImageRepository objects

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-01-14 14:16:13 +02:00
Philip Laine ed9382ec80 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.0 to include `controller-runtime` changes.
- Loggers have been removed from the reconcilers and are 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
  `ReconcilateAtChangedPredicate`, and is now chained with the
  `GenerationChangedPredicate` from `controller-runtime` using
  `predicate.Or`.
- The `leader-election-role` was changed, as leader election now works
  via the `coordination/v1` API.

Other notable changes:

- Use `DeletionTimestamp` of resource object to determine readiness.
- `source-controller` API dependency has been upgraded to `v0.6.0`
  which also uses `controller-runtime` `v0.7.0`.

Co-authored-by: Hidde Beydals <hiddeco@users.noreply.github.com>
Signed-off-by: Philip Laine <philip.laine@gmail.com>
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-01-12 15:05:54 +01:00
Stefan Prodan 600ba2d008
Add readiness/liveness probes
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2020-11-26 10:00:55 +02:00
Stefan Prodan 2437884a97
Change copyright to Flux authors
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2020-10-27 18:52:14 +02:00
Stefan Prodan 633f50e9c9
Implement Prometheus instrumentation
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2020-10-13 15:45:53 +03:00
stefanprodan d90acda9e6 Promote API to v1beta1 2020-09-30 18:21:17 +03:00
stefanprodan c39cad9b84 Add watch all namespaces flag 2020-09-11 15:47:46 +03:00
stefanprodan 132b251923 Use runtime pkg and bump build-push-action version 2020-09-10 15:21:17 +03:00
stefanprodan c86c8d1d3d Configure manager logging and set level to info 2020-09-09 15:15:17 +03:00
stefanprodan bd2fdeba1f Use logger package from fluxcd/pkg
Update source-controller/api to v0.0.11, client-go to v0.18.8 and controller-runtime to v0.6.2
2020-08-21 12:42:45 +03:00
stefanprodan 1bf1534b90 Setup production logging
For production the log format is JSON, the timestamps format is ISO8601
and stack traces are logged when the level is set to debug.
2020-07-13 11:56:53 +03:00
stefanprodan 368c13af28 Implement GitRepository hook 2020-07-03 18:32:34 +03:00
stefanprodan 99fc71c17a Add receiver to API 2020-07-03 16:38:17 +03:00
stefanprodan c0e02990e6 Format imports 2020-07-01 17:40:33 +03:00
stefanprodan 81fd558328 Change ports: 8080 for metrics and 9090 for events 2020-07-01 16:54:27 +03:00
stefanprodan 01d5660043 Initialize resources 2020-07-01 16:35:05 +03:00
stefanprodan ab9c5a74fd Init HTTP server 2020-07-01 12:58:17 +03:00
stefanprodan 86c610aabf Add Alert API spec 2020-06-30 09:25:08 +03:00
stefanprodan 8f35be0055 Add Provider API spec 2020-06-30 08:57:02 +03:00
stefanprodan a0ab3df81f Init controller 2020-06-29 15:45:22 +03:00