How to hide a column with Kubectl

Viewed 14504

I use a tmuxinator to generate a tmux window that watchs the output of some kubectl commands like:

watch -n 5 kubectl get pods/rc/svc/pv/pvc

But sometimes the output of Kubectl get too wide, i.e the selector column after rolling updates, and I would like not to show it on my setup. How do I do this with kubectl alone?

awk or cut can do the job too, but I could not figure out a way of doing this without loosing the table formating.

2 Answers

Rather than using a second tool/binary like awk and column. you can use the flag -o=custom-columns in this way: kubectl get pods --all-namespaces -o=custom-columns=NAME:.metadata.name,Namespace:.metadata.namespace

This is also an alternative and easy way to output custom columns than go-templates or jsonpath!

Related