Commit Graph

51 Commits

Author SHA1 Message Date
Matheus Pimenta e95f8d5b38
[RFC-0010] Introduce feature gate
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-05-19 14:15:57 +01:00
Matheus Pimenta c32f9e1559
Reintroduce default state machine for Provider controller
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-05-05 22:00:46 +01:00
Dipti Pai 0beb3d02f7 Managed Identity support for Azure Event Hubs. Changes include -
- If authentication token is not specified in provider, attempt to get the token using workload identity.
= Add new field .spec.serviceAccountName to support multi-tenant workload identity as defined in RFC-0010 to use an identity with a service account other than the notification-controller.
- Use proxy to get the token if specified in provider spec.
- Cache the tokens if enabled in the notification controller options.
- If address has SAS connection string, use that for authentication, this takes priority over token-authentication
- If static JWT token is specified in the secret reference, use it for authentication, this takes priority over workload identity-acquired token.
- Update RBAC for notification-controller to be able to create service token requests.
- Add unit tests for the 3 authentication mechanisms (SAS, JWT, managed identity).
- Add documentation for using single-tenant and multi-tenant approaches of workload identity with azureeventhub provider.
- Add operation post to github helpers and provider controller for cache event metrics
- Enable token cache by default.

Signed-off-by: Dipti Pai <diptipai89@outlook.com>

review comments

Signed-off-by: Dipti Pai <diptipai89@outlook.com>

enable cache by default

Signed-off-by: Dipti Pai <diptipai89@outlook.com>
2025-05-05 12:03:52 -07:00
Matheus Pimenta 4d3a53ac86
Delete cache entries on provider object deletion
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-05-02 13:00:17 +01:00
Dipti Pai bc7166d419 [RFC-007] GitHub App authentication support for github and github-dispatch providers.
- Add providerOpts in notifier to configure authentication options for various providers.
- If token/password are not set to PAT, check if github app details are configured in secret and if found; authenticate using github-app by retrieving app installation token.
- If proxy is specified in the provider spec OR in the secret, configure github app authentication to fetch the installation token over the proxy.
- Add unit tests for providers.
- Update documentation describing the usage of github app authentication with the providers.
- Add token cache to notification controller to cache and re-use the tokens.

Signed-off-by: Dipti Pai <diptipai89@outlook.com>
2025-03-20 14:18:10 -07:00
Matheus Pimenta b362a258fe
Enforce namespace check on receiver
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-01-30 10:27:01 +00:00
Alexey Kuzbekov c85b1eb391
Change default behavior and naming
Signed-off-by: Alexey Kuzbekov <alexey@kuzbekov.me>
2024-08-24 15:29:29 +01:00
Alexey Kuzbekov ab58c812bd
New flag to disable detailed metrics for path
Flag detailed-metrics added to provide a way to disable exposing all accessed paths to the metrics and  prevent potential metrics cardinality explosion

Signed-off-by: Alexey Kuzbekov <alexey@kuzbekov.me>
2024-08-24 15:29:24 +01:00
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