lwolf / kube-cleanup-operator

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

added flag to allow to delete unowned pods too (#1) #37

Closed safanaj closed 4 years ago

safanaj commented 4 years ago

This would allow the cleanup operator to remove also pods that have no OwnerReferences like a "raw" Pod deployed.

lwolf commented 4 years ago

Could you describe the use-case for this change?

safanaj commented 4 years ago

The purpose of this changes is to allow the cleanup operator to delete also pods that were created directly using the kind: Pod so that are no higher level controller like Job,ReplicaSet ... that owns it. I need this changes because where I work we are creating "raw" pods through a "controller/manager" that is not a proper controller in k8s. Am I clear in the purpose of this change?

lwolf commented 4 years ago

I see what you want. But unless I'm missing something, with your change orphaned pods are going to be deleted immediately after creating. Also, why can't you delete the pod using the same system you use to create? Unmanaged pods have unique name so your external system should be able to delete it by name.

lwolf commented 4 years ago

Pod Eviction is now supported in v0.7.0, could you give it a try? Make sure to run it with -legacy-mode=false to be able to use arguments.