Where do I submit events on failure of my custom operator?

7/13/2017

I'm working on a mysql users operator and I'm somewhat stuck on what's the proper way to report any issues.

The plan is to watch on CRD for MysqlUser and create Secrets and mysql users in the specified DB. Obviously, either of that can go wrong, at which point I need to report an error.

Some k8s object track events in the status.conditions. There's also the Event object, but I've only seen that used by kubelet / controllermanager insofar.

If say, I have a problem creating mysql user because my operator cannot talk to mysql, but otherwise the CRD is valid, should it go to event or to CRD's status?

-- Farcaller
kubernetes
kubernetes-go-client

2 Answers

7/21/2017

CRDs do not have a status part yet (1.7). Notifying via events is perfectly fine, that's the reason for having them in the first place.

-- Michail Kargakis
Source: StackOverflow

7/20/2017

This sounds similar to events reported from volume plugin (kubelet) where, for example, kubelet is unable to mount a volume from NFS server because server address is invalid, thus can not take to it.

Tracking events in status.conditions is less useful in this scenario since users typically have no control over how kubelet (or operator in your case) interacts with underline resources. In general, status.conditions only signals the status of the object, not why it is in this condition.

This is just my understanding of how to make the choice. I don't know if there is any rules around it.

-- ddysher
Source: StackOverflow