Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/micnncim/kubectl-reap
kubectl plugin that deletes unused Kubernetes resources
https://github.com/micnncim/kubectl-reap
krew kubectl kubectl-plugin kubernetes
Last synced: about 1 month ago
JSON representation
kubectl plugin that deletes unused Kubernetes resources
- Host: GitHub
- URL: https://github.com/micnncim/kubectl-reap
- Owner: micnncim
- License: apache-2.0
- Created: 2020-08-17T08:20:01.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-05-19T08:21:45.000Z (over 1 year ago)
- Last Synced: 2024-09-29T05:26:34.103Z (about 2 months ago)
- Topics: krew, kubectl, kubectl-plugin, kubernetes
- Language: Go
- Homepage:
- Size: 294 KB
- Stars: 197
- Watchers: 7
- Forks: 16
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-sysadmin-tools - kubectl-reap - is a kubectl plugin that deletes unused Kubernetes resources (Kubernetes / Kubernetes tools)
README
# kubectl-reap
[![actions-workflow-test][actions-workflow-test-badge]][actions-workflow-test]
[![release][release-badge]][release]
[![codecov][codecov-badge]][codecov]
[![pkg.go.dev][pkg.go.dev-badge]][pkg.go.dev]
[![license][license-badge]][license]`kubectl-reap` is a kubectl plugin that deletes unused Kubernetes resources.
![screencast](/docs/assets/screencast.gif)
Supported resources:
| Kind | Condition |
| ----------------------- | ---------------------------------------------------------- |
| Pod | Not running |
| ConfigMap | Not referenced by any Pods or ReplicaSet |
| Secret | Not referenced by any Pods, ReplicaSet, or ServiceAccounts |
| PersistentVolume | Not satisfying any PersistentVolumeClaims |
| PersistentVolumeClaim | Not referenced by any Pods |
| Job | Completed |
| PodDisruptionBudget | Not targeting any Pods |
| HorizontalPodAutoscaler | Not targeting any resources |Since this plugin supports dry-run as described below, it also helps you to find resources you misconfigured or forgot to delete.
Before getting started, read [the caveats of using this plugin](#caveats).
## Installation
Download precompiled binaries from [GitHub Releases](https://github.com/micnncim/kubectl-reap/releases).
### Via [Krew](https://github.com/kubernetes-sigs/krew)
```
$ kubectl krew install reap
```### Via Homebrew
```
$ brew tap micnncim/kubectl-reap https://github.com/micnncim/kubectl-reap
$ brew install kubectl-reap
```### Via Go
```
$ go get github.com/micnncim/kubectl-reap/cmd/kubectl-reap
```## Examples
### Pods
In this example, this plugin deletes all Pods whose status is not `Running`.
```console
$ kubectl get po
NAME READY STATUS RESTARTS AGE
pod-running 1/1 Running 0 10s
pod-pending 0/1 Pending 0 20s
pod-failed 0/1 Failed 0 30s
pod-unknown 0/1 Unknown 0 40s
job-kqpxc 0/1 Completed 0 50s$ kubectl reap po
pod/pod-pending deleted
pod/pod-failed deleted
pod/pod-unknown deleted
pod/job-kqpxc deleted
```### ConfigMaps
In this example, this plugin deletes the unused ConfigMap `config-2`.
```console
$ kubectl get cm
NAME DATA AGE
config-1 1 0m15s
config-2 1 0m10s$ cat <
[actions-workflow-test]: https://github.com/micnncim/kubectl-reap/actions?query=workflow%3ATest
[actions-workflow-test-badge]: https://img.shields.io/github/workflow/status/micnncim/kubectl-reap/Test?label=Test&style=for-the-badge&logo=github[release]: https://github.com/micnncim/kubectl-reap/releases
[release-badge]: https://img.shields.io/github/v/release/micnncim/kubectl-reap?style=for-the-badge&logo=github[codecov]: https://codecov.io/gh/micnncim/kubectl-reap
[codecov-badge]: https://img.shields.io/codecov/c/github/micnncim/kubectl-reap?style=for-the-badge&logo=codecov[pkg.go.dev]: https://pkg.go.dev/github.com/micnncim/kubectl-reap?tab=overview
[pkg.go.dev-badge]: http://bit.ly/pkg-go-dev-badge[license]: LICENSE
[license-badge]: https://img.shields.io/github/license/micnncim/kubectl-reap?style=for-the-badge