k8s-cleaner - Kubernetes Controller that identifies, removes, or updates stale/orphaned or unhealthy resources
Introduction to k8s-cleaner Reports
Users have the ability to instruct the k8s-cleaner to generate a report with all the resources deleted or modified.
The k8s-cleaner will create a Report instance based on the name of the Report name.
Example - Report Defintion
Cleaner Definition with Notifications set to type CleanerReport
---
apiVersion: apps.projectsveltos.io/v1alpha1
kind: Cleaner
metadata:
name: cleaner-with-report
spec:
schedule: "0 * * * *"
action: Delete # Delete matching resources
resourcePolicySet:
resourceSelectors:
- namespace: test
kind: Deployment
group: "apps"
version: v1
notifications:
- name: report
type: CleanerReport
Validation
Report Output
apiVersion: apps.projectsveltos.io/v1alpha1
kind: Report
metadata:
creationTimestamp: "2023-12-17T17:05:00Z"
generation: 2
name: cleaner-with-report
resourceVersion: "1625"
uid: dda9a231-9a51-4133-aeb5-f0520feb8746
spec:
action: Delete
resourceInfo:
- resource:
apiVersion: apps/v1
kind: Deployment
name: my-nginx-deployment
namespace: test
metadata.creationTimestamp (and resourceVersion, once the Report has been updated by a later run) already tell you when the report was last generated, so nothing about timing is duplicated on each entry.
Rollback
When the owning Cleaner also has rollback configured, each entry in the Report additionally carries a fullResource field: the resource exactly as it was right before Cleaner deleted or transformed it. This is what allows the most recent execution to be reverted. See the Rollback page for details, including how to trigger it.