Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in_kubernetes_events: Efficiently stream kubernetes events via watch #8351

Merged
merged 3 commits into from
Jun 24, 2024

Conversation

ryanohnemus
Copy link
Contributor

@ryanohnemus ryanohnemus commented Jan 4, 2024

Change in_kubernetes_events plugin to watch kubernetes events after requesting the event list. Instead of polling for the full event list every 500ms (default), an initial full events list is requested and then is a watch is requested. The watch will create an efficient http chunked stream that will push events as they are added, modified, or deleted from the cluster. The interval_sec and interval_nsec plugin config options now act as a reconnect timer if the watch stream is ended, instead of timer to re-poll the k8s cluster.

Potentially Breaking: this will require the kubernetes role used by fluent-bit to have watch permission in addition to the current list and get permissions.

Fixes #8315

Leaving in draft as this is dependent on both #8316 & #8323, will rebase and move out of draft after those are reviewed/merged.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • [ X] Example configuration file for the change
[INPUT]
    name          kubernetes_events
    tag           k8s_events
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • Run local packaging test showing all targets (including any new ones) build.
  • Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

plugins/in_kubernetes_events/kubernetes_events.c Outdated Show resolved Hide resolved
plugins/in_kubernetes_events/kubernetes_events.c Outdated Show resolved Hide resolved
plugins/in_kubernetes_events/kubernetes_events.c Outdated Show resolved Hide resolved
plugins/in_kubernetes_events/kubernetes_events.c Outdated Show resolved Hide resolved
plugins/in_kubernetes_events/kubernetes_events.c Outdated Show resolved Hide resolved
plugins/in_kubernetes_events/kubernetes_events.c Outdated Show resolved Hide resolved
plugins/in_kubernetes_events/kubernetes_events.c Outdated Show resolved Hide resolved
plugins/in_kubernetes_events/kubernetes_events.c Outdated Show resolved Hide resolved
plugins/in_kubernetes_events/kubernetes_events.c Outdated Show resolved Hide resolved
plugins/in_kubernetes_events/kubernetes_events.c Outdated Show resolved Hide resolved
@ryanohnemus
Copy link
Contributor Author

@edsiper - just force pushed a new version of this. I still have this PR draft mode because it was branched off of 2 other PRs: #8316 & #8323. I was assuming it would be easier to review those each individually and then I'd rebase this one with a smaller set of changes to review, but if you'd prefer to just do them all in one change PR review/merge, I can move this pr to ready to review.

@edsiper edsiper added this to the Fluent Bit v3.0.0 milestone Jan 10, 2024
@ryanohnemus ryanohnemus force-pushed the feature/in_k8s_watch branch 2 times, most recently from 8639849 to 589a7cb Compare January 16, 2024 20:16
@ryanohnemus
Copy link
Contributor Author

@pwhelan @edsiper @lecaros - this fell out of the next milestone with the last few 3.0 releases but is still ready to go. Can this be added to the existing 3.0.7 milestone? Thank you

Potentially breaking change as it now requires the
rbac used by fluent-bit to have 'watch'.

Uses a k8s watch instead of http api polling to
stream k8s events from the kube api server

Signed-off-by: ryanohnemus <ryanohnemus@gmail.com>
Signed-off-by: ryanohnemus <ryanohnemus@gmail.com>
Signed-off-by: ryanohnemus <ryanohnemus@gmail.com>
@ryanohnemus
Copy link
Contributor Author

Rebased to fix merge conflict.

@edsiper @pwhelan @lecaros could this be tagged in the 3.1.0 milestone so it does not get missed? Thank you!

@patrick-stephens
Copy link
Contributor

We probably should update docs as well, particularly with the RBAC change. Could you link a docs PR @ryanohnemus ?

Do we have any int tests for this btw?

ryanohnemus added a commit to ryanohnemus/fluent-bit-docs that referenced this pull request Jun 19, 2024
fluent/fluent-bit#8351

Signed-off-by: ryanohnemus <ryanohnemus@gmail.com>
@ryanohnemus
Copy link
Contributor Author

@patrick-stephens added doc via fluent/fluent-bit-docs#1396

No int tests, but I added unit tests for the plugin in this PR.

@edsiper edsiper merged commit b20df67 into fluent:master Jun 24, 2024
92 checks passed
lecaros pushed a commit to fluent/fluent-bit-docs that referenced this pull request Aug 16, 2024
* in_kubernetes_events: add k8s permission details
fluent/fluent-bit#8351

Signed-off-by: ryanohnemus <ryanohnemus@gmail.com>

* Update pipeline/inputs/kubernetes-events.md

Co-authored-by: Adam Locke <adam.locke@chronosphere.io>
Signed-off-by: Ryan Ohnemus <ryanohnemus@users.noreply.github.com>

* Update pipeline/inputs/kubernetes-events.md

Co-authored-by: Adam Locke <adam.locke@chronosphere.io>
Signed-off-by: Ryan Ohnemus <ryanohnemus@users.noreply.github.com>

* Add hard return to break section

Signed-off-by: Adam Locke <adam.locke@chronosphere.io>

---------

Signed-off-by: ryanohnemus <ryanohnemus@gmail.com>
Signed-off-by: Ryan Ohnemus <ryanohnemus@users.noreply.github.com>
Signed-off-by: Adam Locke <adam.locke@chronosphere.io>
Co-authored-by: Adam Locke <adam.locke@chronosphere.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-required ok-package-test Run PR packaging tests
Projects
None yet
5 participants