I’ve been leading the Krew “kubectl plugin manager” (a Kubernetes sub-project). Today, Krew is used to distribute over 70 kubectl plugins. This week, I finally took some time to write my first proper plugin.
Meet kubectl tree!
I'm announcing a new fun kubectl subcommand:
— ahmet alp balkan (@ahmetb) January 2, 2020
🌲 kubectl tree
It lets you explore Kubernetes object ownerships in a visual tree view.
Get it today: https://t.co/mhVfAH1ila pic.twitter.com/gqPaYb4HeQ
This plugin shows you which Kubernetes objects are owned by which ones. It does this by querying all Kubernetes objects available, and looking at their <code>ownerReferences</code> field.
For example, on a Deployment object, it shows ReplicaSets owned by the
Deployment, and the Pods owned by those ReplicaSets (in this case,
deleting the Deployment would cause a cascading deletion of these sub-resources
for garbage collection):

The main purpose of the plugin is troubleshoot which objects are involved in
making a Kubernetes component work. For example, on a Knative Service (a.k.a.
KService), it shows underlying resources that make the app work:

As expected, the plugin is distributed through the Krew plugin manager for kubectl. Hope you try it out, and send me your feedback!
Special shout-out to Nima Kaviani as his knative-inspect tool has inspired me to write a generic version of his tool that’s not limited to Knative ––or rather, I’ve been asking him to do this for a while. :)