Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for json output #10

Closed
shrinandj opened this issue Aug 5, 2021 · 3 comments
Closed

Add option for json output #10

shrinandj opened this issue Aug 5, 2021 · 3 comments

Comments

@shrinandj
Copy link

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.

@yogeshkk
Copy link
Owner

yogeshkk commented Aug 5, 2021

@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

@shrinandj
Copy link
Author

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.

@yogeshkk
Copy link
Owner

yogeshkk commented Aug 9, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants