nolar / kopf

A Python framework to write Kubernetes operators in just a few lines of code
https://kopf.readthedocs.io/
MIT License
2.11k stars 159 forks source link

Changing the "from" name in the Kubernetes events #994

Open martinohansen opened 1 year ago

martinohansen commented 1 year ago

Is it possible to change the "from" name that shows up in the Kubernetes events on a resource while using the kopf.Logging class? We are running multiple kopf operators and would like to know from which the messages are coming.

Events:
  Type    Reason      Age        From     Message
  ----    ------      ----       ----     -------
  Normal  Logging     2m20s      kopf     Handler 'roller' succeeded.
prestonr83 commented 1 year ago

I would like to know this too.

prestonr83 commented 1 year ago

Its hard coded https://github.com/nolar/kopf/blob/c2664796a13bafab82fc2ed06855d959726734e3/kopf/_cogs/clients/events.py#L66 this would need to be parameterized to allow changing or you can fork and just statically change it.

lorrx commented 9 months ago

I would also like to have this feature. Perhaps the PostingSettings could be extended with an additional option? The settings are passed to the post_event() function, so this should be easy to implement.

But: Can side effects occur if this option is parameterized? There will probably be a reason for the hard coding, right?