kube-cleanup-operator icon indicating copy to clipboard operation
kube-cleanup-operator copied to clipboard

Add support for annotation-based customizations

Open lwolf opened this issue 5 years ago • 2 comments

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

lwolf avatar Mar 22 '21 18:03 lwolf

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:

  1. Support configuration option like --respect-annotations with false by default for compatibility
  2. Add at least main annotation which disables cleanup on exact job/pod kube-cleanup-operator.lwolf.github.com/disabled to disable cleanup for the specific class of pods/jobs for debugging purposes.
  3. Support configurable options for jobs/pods delete-successful-after, delete-failed-after
  4. Support pods only configuration delete-orphaned-after, delete-evicted-after, delete-pending-after

RocketRaccoon avatar Mar 22 '21 20:03 RocketRaccoon

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/.

lwolf avatar Mar 28 '21 17:03 lwolf