feat(sweep): cleanup detectors — orphaned Services, unused PVCs, idle namespaces, zombies#17
Merged
Merged
Conversation
… namespaces, zombies New `kubetidy sweep` command (Phase 3 "cleanup detectors") — the literal tidy beyond rightsizing. Read-only; it surfaces removable junk and never deletes anything: - orphaned Services — selector matches no pods (dead routing target) - unused PVCs — not mounted by any pod, with an estimated $/mo storage cost - idle namespaces — no running workloads (system namespaces excluded) - zombie workloads — Deployments/StatefulSets scaled to 0 replicas - internal/cleanup: pure detectors over listed objects (Detect(Inputs) []Finding), fully fake-testable; estimates PVC cost from requested size × --storage-cost. - internal/cli/sweep.go: gathers objects via client-go and renders a grouped, dollar-aware table (or --output json); `sweepWithClients` is hermetically tested. - Named `sweep` because `cleanup` is already an alias for `uninstall`. - docs: README sweep section, ROADMAP checked off, CHANGELOG (v0.1.2). Coverage: cleanup 92.5%. Full build/vet/fmt/test/lint green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the roadmap's cleanup detectors (Phase 3) as a new read-only command,
kubetidy sweep— the literal "tidy" beyond rightsizing.What it finds
How
internal/cleanup— pure detectors over listed objects (Detect(Inputs) []Finding), fully fake-testable. PVC cost = requested size ×--storage-cost($/GiB-month, default 0.10).internal/cli/sweep.go— gathers Services/Pods/PVCs/Deployments/StatefulSets/DaemonSets/Namespaces via client-go and renders a grouped, dollar-aware table (or--output json).sweepWithClientsis hermetically tested with fake clientsets.sweepbecausecleanupis already an alias foruninstall.Docs
README
sweepsection, ROADMAP item checked off, CHANGELOG (v0.1.2).Tests
internal/cleanup92.5% (each detector + cost + totals),sweepWithClients+ render covered. Fullgo build/vet/gofmt/test ./...+golangci-lint(0 issues) green.Possible follow-ups
sweep→diff/prto emitkubectl delete/ GitOps deletions for review.