kubectl janitor
is a kubectl plugin that assists in finding objects in a problematic state in your Kubernetes cluster.
Troubleshooting Kubernetes clusters sometimes requires a combination of kubectl
commands and other command-line tools such as jq to do correlations around the issues that the various objects might have. Moreover, sometimes the supported options of the --field-selector
flag might be limited.
During troubleshooting scenarios, people need to identify the issues quickly without worrying about remembering all the different command combinations. The primary goal of this plugin is to collect some commonly executed kubectl command patterns to identify objects in a problematic state in the cluster and reduce the cognitive load for people troubleshooting.
You can install kubectl janitor
using the Krew, the package manager for kubectl plugins.
Once you have Krew installed run the following command:
kubectl krew install janitor
Check the release page for the full list of pre-built assets.
- Download one of the releases that are compatible with your os/arch.
- Unzip to get
kubectl-janitor
- Add it to your
PATH
or move it to a path already in inPATH
(i.e.,/usr/local/bin
)
go get -u github.com/dastergon/kubectl-janitor/cmd/kubectl-janitor
This command will download and compile kubectl-janitor
.
To get the full list of commands with examples:
kubectl janitor
kubectl janitor pods unscheduled
kubectl janitor pods unhealthy
kubectl janitor pods unready
kubectl janitor pods status
kubectl janitor jobs failed
kubectl janitor pvs unclaimed
kubectl janitor pvcs pending
You can use the -A
or --all-namespaces
flag to search for objects in all namespaces.
You can use the --no-headers
flag to avoid showing the column names.
If you have installed the plugin via the krew
command. You can remove the plugin by using the same tool:
kubectl krew uninstall kubectl-janitor
Or, you can "uninstall" this plugin from kubectl by simply removing it from your PATH:
rm /usr/local/bin/kubectl-janitor
Pavlos Ratis @dastergon.