The Kubebuilder V3 documentation explains that it talks about "How to batch multiple events into a single reconciliation call". However, I could not find any information about event management in this documentation.
Could you please provide information/code sample about how to send Events with Kubebuilder-v3/operator-sdk
?
It seems this page might help in understanding how to send events: https://book-v1.book.kubebuilder.io/beyond_basics/creating_events.html using the standard client-go EventRecorder
However, it is not up to date for Kubebuilder v3.
Thanks @coderanger for your help on this topic, on the k8s stack channel!
This part from the official documentation should answer your question:
This business logic of the Controller is implemented in the
Reconcile
function. This function takes the Namespace and Name of a ContainerSet, allowing multiple Events to be batched together into a single Reconcile call. The function shown here creates or updates a Deployment using the replicas and image specified in ContainerSet.Spec. Note that it sets an OwnerReference for the Deployment to enable garbage collection on the Deployment once the ContainerSet is deleted.
- Read the ContainerSet using the NamespacedName
- If there is an error or it has been deleted, return
- Create the new desired DeploymentSpec from the ContainerSetSpec
- Read the Deployment and compare the Deployment.Spec to the ContainerSet.Spec
- If the observed Deployment.Spec does not match the desired spec
- Deployment was not found: create a new Deployment
- Deployment was found and changes are needed: update the Deployment
There you can also find example with the code.