Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes: create events for custom resources

I have created a custom resource definition (CRD) and a custom resource (CR) in my Kubernetes cluster, but in my CR controller, how do I create Kubernetes events which are attached to my custom resource? I hope with events, users will be able to see important messages associated with the CR when they run kubectl describe <cr>.

like image 978
Dagang Avatar asked Oct 16 '22 11:10

Dagang


1 Answers

You're looking for an operator. There are already a few pre-written ones out there, check OperatorHub. They are essentially controllers for custom resources, watching for events and acting on them.

You can also write your own, e.g. with the Operator SDK. When you write your own, you can update the status of the CR, depending on what your operator should do, which then shows up when calling kubectl describe.

A good start might be this post on Operators, and this here for listening to events from your custom resources.

like image 75
char Avatar answered Oct 19 '22 02:10

char