Closed shrinandj closed 2 years ago
@shrinandj
You can run this in K8s as deployment via below
kubectl apply -f deploy/manifest.yaml
Then It will continue to run in background and exporting metrics such under "k8s_unused_resources". You can configure Prometheus to scrape it refer this.
Once metrics started appearing in Promethues you can add alert rule in Prometheus to send alert to respective stakeholder. (I will add few sample rule as soon as possible). Also you can Grafana dashboard(provided under deploy/k8sPurger Dashboard.json) which can show you all unused resource in each namespace.
Sample metrics is as below k8s_unused_resources{name="Test_secret",namespaces="default",type="Secrets"} 1.0
Awesome. Thanks for the detailed reply.
However, instead of going through additional steps like the above, it might be easier still to have a -o json
output option.
@shrinandj
I have integrated with Prometheus as Prometheus has emerged as the de-facto open-source standard for monitoring Kubernetes. If you have Prometheus you have zero configuration just need to add alerts.
The nice box output is generated by me. So adding -o json is a bit of effort from my side also people need to add their logic to get json output process to send an alert.
I am not sure how many people are ready to put that effort so I will keep this issue open if we see traction on this issue will implement the same.
Cool tool!!
This will enable running K8Spurger as a Cronjob (or Jenkins a job) periodically and do some additional processing of the output. E.g. Send notifications to namespace owners about unused resources in their namespace.