Support label selectors
Matt343 opened this issue · 2 comments
Matt343 commented
The tree command currently requires you to specify a single resource to use as the root. It would be helpful to instead be able to use a label selector (like kubectl get -l
) and then build trees from each of the resources that match that selector.
ahmetb commented
This tool is currently a single-rooted tree, by design.
You can easily do
for res in $(kubectl get -l ...); do
kubectl tree "$res"
done
and make use of unix tool composability. :)
I don't want to open a can of worms like "what happens if one of the requests fail", "how do we render multiple trees" etc.
remram44 commented
k9s supports this ("xray" command) if you are looking for an alternative.
My own workaround (bashrc):
kt(){
for i in $(kubectl get -o jsonpath='{.metadata.name}{range .items[*]}{.metadata.name}{"\n"}{end}' "$@"); do
kubectl tree "$1" "$i"
done
}
This allows kt deploy
, kt deploy webserver
, kt deploy -l app=webserver
, etc.