lwolf / kube-cleanup-operator

Kubernetes Operator to automatically delete completed Jobs and their Pods
MIT License
498 stars 109 forks source link

Support cleanup Pods whose owner is not Job #98

Open fpt-harley-haitx5 opened 3 weeks ago

fpt-harley-haitx5 commented 3 weeks ago

Hi. I have an issue that Pods are not chosen to be deleted if it has owner that's not a Job. In my case I use Tekton pipelines, which will create multiple pods to run the pipelines, and each pod has an owner with kind "TaskRun", not "Job".

I've taken a look at the logic to determine whether a pod is chosen to be deleted: https://github.com/lwolf/kube-cleanup-operator/blob/538f00d447db507f528fd6f94fa2c3d81b9302f3/pkg/controller/pod.go#L27-L73. It seems pods can only be deleted in these 2 cases:

Is it okay to have additional flag to allow deletion of pods that have owner different than Job ? Thanks in advance.

lwolf commented 2 weeks ago

Hi. Sorry for the late reply.

Historically the idea was to only cleanup pods owned by jobs and abandoned ones. But with so many custom operators these days I think it's reasonable to be able to specify additional owners