Add support for annotation-based customizations
There is a use case when jobs/pods need to be "cleaned up" after a different timeout. It should be possible to support it by considering annotations on pods/jobs before making a "clean up" decision.
https://github.com/lwolf/kube-cleanup-operator/pull/71#issuecomment-804241375
The main idea behind using labels is an option to use LabelSelector on ListFunc and WatchFunc. So it looks like that implementing labelSelector does not contradicts with annotation-based logic in general, but the same logic could be implemented with FieldSelector on annotations. Any way, solution with annotations could be done in this way:
- Support configuration option like
--respect-annotationswith false by default for compatibility - Add at least main annotation which disables cleanup on exact job/pod
kube-cleanup-operator.lwolf.github.com/disabledto disable cleanup for the specific class of pods/jobs for debugging purposes. - Support configurable options for jobs/pods
delete-successful-after,delete-failed-after - Support pods only configuration
delete-orphaned-after,delete-evicted-after,delete-pending-after
I agree that labelSelector doesn't contradict annotation-based logic. Merged the PR.
Your plan for the annotations looks great.
The only thing I'd change is the prefix for the annotations: kleaner.lwolf.org instead of kube-cleanup-operator.lwolf.github.com/.