Resource Reaper is a Kubernetes controller that automatically manages resource lifecycles using TTL (Time-To-Live) annotations. It helps maintain cluster hygiene by automatically cleaning up resources that have exceeded their specified lifetime.
- TTL-based Cleanup: Automatically delete resources when they exceed their time-to-live
- Flexible Annotations: Use simple annotations to specify resource lifetimes
- Multiple Resource Support: Works with various Kubernetes resources (Pods, Deployments, etc.)
- Leader Election: Supports high availability deployments
- Metrics: Prometheus metrics for monitoring cleanup operations
- Helm Installation: Easy deployment using Helm chart
- Resource Efficient: Minimal resource footprint
- Kubernetes Native: Built using controller-runtime framework
Install using Helm:
helm repo add resource-reaper https://abhinavgrover15.github.io/resource-reaper
helm repo update
helm install resource-reaper resource-reaper/resource-reaper
Add TTL annotation to your resources:
annotations:
reaper.resource/ttl: "24h" # Resource will be deleted after 24 hours
Resource Reaper watches Kubernetes resources and automatically deletes them when their TTL expires. This is useful for:
- Cleaning up temporary resources
- Managing development/test environments
- Automatic cleanup of completed jobs
- Time-limited demo resources
- Core Resources: Pods, Services, ConfigMaps, Secrets
- Apps Resources: Deployments, StatefulSets, DaemonSets
- Batch Resources: Jobs, CronJobs
Add the resource-reaper/ttl
annotation to any supported resource:
apiVersion: v1
kind: Pod
metadata:
name: test-pod
annotations:
resource-reaper/ttl: "2h" # Pod will be deleted after 2 hours
spec:
containers:
- name: nginx
image: nginx:latest
Supported TTL formats:
- Hours: "1h", "2h"
- Minutes: "30m", "45m"
- Days: "2d", "7d"
- Immediate deletion: "0s"
- Apply the RBAC configuration:
kubectl apply -f https://raw.githubusercontent.com/abhinavgrover15/resource-reaper/main/config/rbac.yaml
- Deploy the controller:
kubectl apply -f https://raw.githubusercontent.com/abhinavgrover15/resource-reaper/main/config/deployment.yaml
- Add the Helm repository:
helm repo add resource-reaper https://abhinavgrover15.github.io/resource-reaper
helm repo update
- Install the chart:
helm install resource-reaper resource-reaper/resource-reaper
- Clone the repository:
git clone https://github.com/abhinavgrover15/resource-reaper.git
cd resource-reaper
- Build the container:
docker build -t resource-reaper:latest .
- Deploy to Kubernetes:
kubectl apply -f config/
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.