hjacobs / kube-janitor

Clean up (delete) Kubernetes resources after a configured TTL (time to live)
GNU General Public License v3.0
472 stars 40 forks source link

Delete notification #24

Closed angelbarrera92 closed 5 years ago

angelbarrera92 commented 5 years ago

Hi thanks for this awesome project.

I am thinking in some notification mechanism when a resource is going to be deleted soon.

Is this possible? Something like a webhooks or callbacks to an specific endpoint. Make sense for you?

hjacobs commented 5 years ago

This could make sense, easiest would be to emit a Kubernetes event and use some other mechanism to notify on Kubernetes events.

angelbarrera92 commented 5 years ago

Sounds good if a custom event could be sent from this project. Then, other components would be able to make some actions. Maybe notify via email, twitter, telegram...

The event could be parametrized with the amount of time before expire an object will expire.

So, if you configure a expiration time in a namespace to be deleted at 08:00, and the event is configured to notify 1h before, the event must be sent at 07:00 :)

It could be interesting!

angelbarrera92 commented 5 years ago

I think i can implement it. Are you (@hjacobs) open to integrate this feature?

hjacobs commented 5 years ago

@angelbarrera92 yes, but it should be optional (opt-in)

angelbarrera92 commented 5 years ago

Hi, thanks for merge the pull request. Are you thinking in publishing a new release whit this feature?

Thanks!

hjacobs commented 5 years ago

Released: https://github.com/hjacobs/kube-janitor/releases/tag/0.6

hjacobs commented 5 years ago

Example events:

2m32s       Normal    DeleteNotification     ReplicaSet                ReplicaSet nginx-dbddb74b8 will be deleted at 2019-03-23T22:24:30Z (annotation janitor/ttl is set)
2m32s       Normal    DeleteNotification     Deployment                Deployment nginx will be deleted at 2019-03-23T22:24:30Z (annotation janitor/ttl is set)