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!

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 ownerReferences 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):

kubernetes object tree for a Deployment

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:

kubernetes object tree for a Knative Service

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. :)