A CLI tool for cleaning up Kubernetes resources in specific states
Project description
Pod Reaper (podr) 💀
Tired of lingering Kubernetes pods and jobs cluttering your namespaces? Meet Pod Reaper, the ultimate cleanup tool for your cluster.
podr is a simple but powerful CLI tool that finds Kubernetes pods and jobs in a specific state (like Succeeded, Failed, or Error) and deletes them. Stop manually running kubectl delete and automate your cluster hygiene!
The Problem: A Messy Cluster
In a dynamic Kubernetes environment, completed pods (Succeeded) and failed jobs (Failed) can accumulate quickly. This digital debris clutters your cluster, making it difficult to monitor and manage. While a few leftover resources might seem harmless, they can eventually:
- Obscure real issues: A long list of failed pods makes it hard to spot new, critical failures.
- Consume resources: In some cases, completed resources can still hold on to claims or other resources.
- Create noise: A messy
kubectl get podsoutput is a daily annoyance for any developer or SRE.
Why Pod Reaper?
- 🎯 Simple & Specific: Target exactly what you want to delete. Clean up
Succeededpods,Failedjobs, or pods in anErrorstate with a single, readable command. - 🤖 Automation-Ready: Generate Kubernetes
CronJobYAML directly from the CLI. Set up a GitOps workflow to keep your cluster clean automatically. - 🛡️ Safe & Predictable: Use the
--dry-runflag to see whatpodrwould delete before making any changes. No surprises. - 🌐 Namespace Flexible: Clean the current namespace, a specific namespace, or all namespaces at once (
-A).
🚀 Installation
Install directly from PyPI:
pip install podr
Usage
The command structure is simple: podr <resource> <state> [options]
| Resource | Supported States |
|---|---|
pods |
Succeeded, Failed, Error, Running, Pending |
jobs |
Completed, Failed, Active |
Examples:
# See which 'Succeeded' pods would be deleted in the 'default' namespace
podr pods Succeeded -n default --dry-run
# Delete all pods in an 'Error' state across the entire cluster
podr pods Error -A
# Delete all 'Completed' jobs in the current namespace
podr jobs Completed
# Generate a CronJob YAML to clean failed jobs every 15 minutes
podr jobs Failed --interval 900 --output
🧪 Development & Testing
podr comes with a full pytest suite and a script to generate test resources in your cluster.
Generating Test Resources
To test podr in a real environment (like minikube), you can generate a sample set of pods and jobs.
-
Target your cluster: Make sure your
kubectlcontext is pointing to the desired test cluster. -
Run the script:
python3 generate_test_resources.py
This will create a new namespace pod-reaper-test and populate it with resources in various states, ready for reaping.
Running the Test Suite
Run the full pytest suite locally:
make test
🙌 How to Contribute
We welcome contributions! Whether it's a bug fix, a new feature, or a documentation improvement, we'd love your help.
- Fork the repository.
- Create a new branch:
git checkout -b my-feature-branch - Set up your development environment:
make install-dev - Make your changes.
- Run the tests:
make test - Submit a pull request!
We'll review your PR as soon as possible.
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file podr-0.1.1.tar.gz.
File metadata
- Download URL: podr-0.1.1.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6543b4deb4648e550d4c9fb225d409349ef8bd10450d6a6e39b334cd5b382451
|
|
| MD5 |
86e6b6e6c194b36b784f1085b47dd8ce
|
|
| BLAKE2b-256 |
35d064eb4cac2478bf5075a07f6fe94d422e24fb43e7bf6fcf4da3a2186fb36c
|
File details
Details for the file podr-0.1.1-py3-none-any.whl.
File metadata
- Download URL: podr-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40fb42ae1ac9f771a6b95586ec3b19b02f51aa1639dea9e23a0933aff0ee4fa2
|
|
| MD5 |
4c1345811ba56f86e0fe253d903ce6c4
|
|
| BLAKE2b-256 |
f6744fdaae3a0eb70daf427d36fab99939abca9a6d72bb7682019b4aa20dc920
|