Kubectl Plugins for Efficient Firefighting: Part 1

Kubernetes is a powerful orchestration platform, and kubectl
is its trusty command-line companion. While kubectl
provides a robust set of commands for managing clusters, firefighting—those high-pressure moments when you need to debug, troubleshoot, or resolve issues quickly—can expose its limitations. Recalling complex commands or chaining multiple ones can slow you down when time is critical. This is where kubectl
plugins shine. They streamline workflows, reduce cognitive load, and save precious seconds in crunch time.
In this first part of a series, I’ll introduce eight kubectl
plugins that have become my go-to tools for firefighting scenarios. These plugins enhance productivity and simplify tasks, but I recommend using them alongside standard kubectl
commands. Relying solely on plugins can create dependency risks, so maintain familiarity with native commands to stay versatile. Let’s dive into the plugins, their uses, and where to find them.
1. kubectx
Use: Quickly switch between Kubernetes contexts and namespaces.
When managing multiple clusters or namespaces, switching contexts with native kubectl
commands can be tedious. kubectx
simplifies this with a single command to list and switch contexts or namespaces, saving time during debugging across environments.
GitHub: https://github.com/ahmetb/kubectx
2. ns
Use: Easily switch between namespaces or set a default namespace.
Similar to kubectx
, the ns
plugin focuses on namespace management. It’s a lightweight alternative for quickly jumping between namespaces without editing kubectl
config files, which is invaluable when isolating issues in specific namespaces.
GitHub: https://github.com/jordanwilson230/kubectl-plugins
3. count
Use: Count Kubernetes resources like pods, deployments, or services.
When assessing the scope of an issue, you often need to know how many resources are running. The count
plugin provides a quick way to tally resources across namespaces, avoiding manual kubectl get
and wc
command combinations.
GitHub: https://github.com/chenjiandongx/kubectl-count
4. crashwatch
Use: Monitor pods for crash loops and alert on failures.
Debugging crashing pods is a common firefighting task. crashwatch
tracks pods in crash loops, providing real-time insights into failures, which helps you pinpoint problematic deployments or containers faster than parsing logs manually.
GitHub: https://github.com/bedirhangull/kubectl-crashwatch
5. evict-pod
Use: Safely evict pods from nodes.
When performing node maintenance or debugging node-specific issues, you may need to evict pods. The evict-pod
plugin simplifies this process, ensuring pods are gracefully rescheduled, reducing disruption compared to manual pod deletions.
GitHub: https://github.com/rajatjindal/kubectl-evict-pod
6. example
Use: Generate example Kubernetes resource manifests.
When troubleshooting, you might need to create test resources quickly. The example
plugin generates sample manifests for pods, deployments, or services, allowing you to experiment without crafting YAML from scratch.
GitHub: https://github.com/seredot/kubectl-example
7. mexec
Use: Execute commands across multiple pods simultaneously.
Debugging often requires running commands in multiple pods to gather data. mexec
lets you execute a command across a set of pods in one go, streamlining tasks like checking logs or environment variables across a deployment.
GitHub: https://github.com/major1201/kubectl-mexec
8. oomd
Use: Identify pods terminated due to Out-Of-Memory (OOM) errors.
OOMKilled errors (exit code 137) are a frequent culprit in pod failures. The oomd
plugin lists pods and containers recently terminated due to OOM issues, including memory requests, limits, and termination times, making it easier to diagnose memory-related problems.
GitHub: https://github.com/jdockerty/kubectl-oomd
Why Use Plugins, But Stay Grounded?
These plugins are lifesavers in high-pressure situations, cutting down on command complexity and speeding up resolution. However, kubectl
itself is a powerful tool with everything you need for most tasks. Plugins are enhancements, not replacements. Regularly practicing native kubectl
commands ensures you’re not caught off guard if a plugin is unavailable or incompatible with your cluster. Balance is key—use plugins for efficiency, but keep your kubectl
skills sharp.
Conclusion
The plugins covered in this post—kubectx
, ns
, count
, crashwatch
, evict-pod
, example
, mexec
, and oomd
—are fantastic tools for Kubernetes firefighting. They simplify context switching, resource monitoring, and debugging, making you more effective when the pressure’s on. Install them via Krew or directly from their GitHub repositories, and give them a try in your next troubleshooting session.
Stay tuned for Part 2, where I’ll explore more kubectl
plugins to supercharge your Kubernetes workflows. In the meantime, keep practicing those native kubectl
commands, and let me know your favorite plugins in the comments!