-
Notifications
You must be signed in to change notification settings - Fork 455
Add stdout support without volume and sidecar #3667
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
base: main
Are you sure you want to change the base?
Add stdout support without volume and sidecar #3667
Conversation
✅ Deploy Preview for tetragon ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Implement JSONStdoutEncoder to write JSON events to stdout with an EVENT: prefix in direct-stdout mode. This allows users to easily filter JSON events from Tetragon logs using `grep '^EVENT:'`. The encoder uses os.Stdout.Write with Sync for efficient output and includes debug logs for troubleshooting. Enhancement cilium#1710 Signed-off-by: Amir Reza Nazarizadeh <[email protected]>
6795ce5
to
dc7cb76
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for tackling this @cy83rc0llect0r
Let's first clarify what export configurations should be available to the user. Currently there are:
- no export (events exposed only via gRPC server)
- export to a file
- export to a file + stdout (via sidecar)
IMO we should keep these configurations available. After quickly going over the PR, my understanding is that (1) no export is no longer an option (2) export to a file but not stdout is no longer an option. What I would expect here is to replace the sidecar with a built-in stdout export, but not break other export configurations. Does it make sense?
I don't have a strong opinion about moving Tetragon diagnostics logs to stderr, but it is a technically a breaking change. Tetragon project documents such changes in the upgrade notes - could you add a point in contrib/upgrade-notes/latest.md
about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is quite a bit of validation and normalization logic here for the export-mode
flag. Could we move it to pkg/option
, when the flag is read and set? I think it's more readable and maintainable that way.
@lambdanis Thank you for the detailed feedback and for clarifying the expected export configurations! I’ve reviewed your comments and would like to outline the current state of the PR, address your concerns, and propose a path forward to ensure all configurations are supported as intended. Current State of the PRThe PR currently implements the following export modes:
Additionally:
Addressing Your FeedbackI understand your concern that all existing configurations (
Looking forward to your feedback! |
e6a3962
to
215be57
Compare
@lambdanis Any comments? |
@cy83rc0llect0r Thank you for the clarification and the wait :)
IMO it's fine to deprecate the Regarding file export. What's the behaviour if the export mode is set to
I thought about it again, and I'm leaning towards reverting the change. The thing is, most of Tetragon logs are not errors, and users might have tooling (e.g. a logs collector) it place that assumes stderr is all errors. This change might have unexpected consequences down the pipeline, while with the |
Add export-mode flag to support none, file, stdout, and file+stdout modes, defaulting to file for backward compatibility. Enhancement cilium#1710 Signed-off-by: Amir Reza Nazarizadeh <[email protected]>
Update startExporter to support file and direct-stdout modes, deprecating the stdout mode. For direct-stdout, use JSONStdoutEncoder in a goroutine to ensure non-blocking event processing. For file mode, retain existing lumberjack.Logger logic. Add fallback to file for invalid modes. Enhancement cilium#1710 Signed-off-by: Amir Reza Nazarizadeh <[email protected]>
Update Helm chart to support export.mode (stdout, file and direct-stdout), with conditional sidecar and volume management. Default to stdout mode for backward compatibility. Enhancement cilium#1710 Signed-off-by: Amir Reza Nazarizadeh <[email protected]>
Enhancement cilium#1710 Signed-off-by: Amir Reza Nazarizadeh <[email protected]>
215be57
to
cf911b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll join Anna here and also it seems the PR needs rebase now, thanks!
Enhancement #1710
Description
This pull request introduces support for
stdout
,file
anddirect-stdout
export modes in Tetragon, addressing the enhancement request in Enhancement #1710. The newdirect-stdout
mode allows users to send JSON events directly to stdout with anEVENT:
prefix, eliminating the need for a sidecar container and volume mounts in Kubernetes deployments. Tetragon internal logs are now sent to stderr, ensuring clean separation from JSON events. The Helm chart is updated to support the newexport.mode
configuration, with conditional sidecar and volume management. Thestdout
mode is deprecated with a fallback tofile
for backward compatibility.The changes include:
JSONStdoutEncoder
withEVENT:
prefix fordirect-stdout
mode, enabling easy filtering of JSON events (e.g.,kubectl logs | grep '^EVENT:'
).logrus
to send Tetragon logs to stderr and addition ofexport-mode
flag inpkg/option/config.go
.startExporter
incmd/tetragon/main.go
to handlefile
anddirect-stdout
modes, withgo exporter.Start()
for non-blocking event processing.export.mode
, disabling sidecar and volume fordirect-stdout
.Use Case Example
Users can now deploy Tetragon in
direct-stdout
mode to simplify Kubernetes setups by removing sidecar dependencies, making it ideal for lightweight deployments or environments where direct log processing (e.g., viakubectl logs | jq
) is preferred. TheEVENT:
prefix allows easy parsing of JSON events, while stderr logs facilitate debugging. Thefile
mode remains available for scenarios requiring persistent event storage.Changelog