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

Generic/global TTL rules for resources without annotation #2

Closed hjacobs closed 5 years ago

hjacobs commented 5 years ago

For test or prototyping environments/clusters, it can be desirable to automatically calculate a TTL for resources based on certain rules, e.g.:

hjacobs commented 5 years ago

Example rule evaluation logs:


DEBUG: Rule require-application-label with JMESPath "!(spec.template.metadata.labels.application)" evaluated for Deployment default/kube-janitor: False
DEBUG: Rule temporary-pr-deployments with JMESPath "starts_with(metadata.name, 'pr-')" evaluated for Deployment default/kube-janitor: False
DEBUG: Rule require-application-label with JMESPath "!(spec.template.metadata.labels.application)" evaluated for Deployment default/nginx: True
DEBUG: Rule require-application-label applies 4d TTL to Deployment default/nginx
DEBUG: Deployment nginx with TTL of 4d is 2:49:13.563265 old