Skip to content

Migrate to new Kubernetes events API - #1267

Open
adri1197 wants to merge 1 commit into
fluxcd:mainfrom
adri1197:event-recorder
Open

adri1197 wants to merge 1 commit into
fluxcd:mainfrom
adri1197:event-recorder

Conversation

@adri1197

@adri1197 adri1197 commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Migrates the controller's event recording from the legacy k8s.io/client-go/tools/record interface to github.com/fluxcd/pkg/runtime/events, which emits structured events.k8s.io/v1 Events, and moves the event payload API from fluxcd/pkg/apis/event/v1beta1 to fluxcd/pkg/apis/event/v1.

  • Replace kuberecorder.EventRecorder with events.Recorder in the Alert, Provider and Receiver reconcilers and in the EventServer.
  • Switch event emission to the event/v1 Eventf signature, adding an explicit Action (Reconciled, Failed, Validating, Fetching) and Related object argument.
  • Migrate all notifier backends from event/v1beta1 to event/v1; the dispatched payload now carries the action field
  • Use mgr.GetEventRecorder / testEnv.GetEventRecorder and events.NewFakeRecorder in tests instead of the client-go equivalents.
  • Document the new relatedObject field and event/v1 reference in the event spec.
  • Bump Kubernetes to 0.37, controller-runtime to 0.25 and the fluxcd/pkg modules as a set

Part of fluxcd/flux2#5761

@adri1197
adri1197 marked this pull request as ready for review March 7, 2026 12:20
@adri1197
adri1197 marked this pull request as draft March 7, 2026 12:32
@matheuscscp

matheuscscp commented Mar 7, 2026

Copy link
Copy Markdown
Member

I think this is a change that needs to be done in fluxcd/pkg first

@adri1197

adri1197 commented Mar 7, 2026

Copy link
Copy Markdown
Contributor Author

I think this is a change that needs to be done in fluxcd/pkg

Is there a reason notification-controller hasn't been migrated to fluxcd/pkg for Events yet? I see it’s already implemented in helm-controller. I'm happy to include that migration here as I've already begun the work.

@matheuscscp

Copy link
Copy Markdown
Member

I think this is a change that needs to be done in fluxcd/pkg

Is there a reason notification-controller hasn't been migrated to fluxcd/pkg for Events yet? I see it’s already implemented in helm-controller. I'm happy to include that migration here as I've already begun the work.

Yes, a very specific one: fluxcd/pkg wraps k8s EventRecorder to fan out to notification-controller. But notification-controller can't send events to itself, hence why it doesn't use it. I guess what I meant is: if we're gonna migrate to the new Event API, it has to start with fluxcd/pkg, which is for the other Flux controllers 👌

@adri1197

adri1197 commented Mar 7, 2026

Copy link
Copy Markdown
Contributor Author

I think this is a change that needs to be done in fluxcd/pkg

Is there a reason notification-controller hasn't been migrated to fluxcd/pkg for Events yet? I see it’s already implemented in helm-controller. I'm happy to include that migration here as I've already begun the work.

Yes, a very specific one: fluxcd/pkg wraps k8s EventRecorder to fan out to notification-controller. But notification-controller can't send events to itself, hence why it doesn't use it. I guess what I meant is: if we're gonna migrate to the new Event API, it has to start with fluxcd/pkg, which is for the other Flux controllers 👌

Got it! Will start with fluxcd/pkg, then. Thanks a lot! 😃

@adri1197
adri1197 force-pushed the event-recorder branch 2 times, most recently from 8fea4da to 1bf9d49 Compare May 9, 2026 18:15
@adri1197
adri1197 force-pushed the event-recorder branch 3 times, most recently from 1ff4d3d to 7131cf1 Compare June 22, 2026 16:43
@adri1197
adri1197 marked this pull request as ready for review September 16, 2026 21:49
Replace deprecated record.EventRecorder with events.EventRecorder
from k8s.io/client-go/tools/events. Update all controllers, event
server, and tests to use the new API signature.

Signed-off-by: Adrian Fernandez de la Torre <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants