[Solved] How to hide a column with Kubectl

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!

There is no explicit support for selecting a subset of columns in kubectl, but there are a few ways to accomplish this. You already mentioned awk which can be pared with column -t to get a nice table format:

$ kubectl get pods --all-namespaces | awk {'print $1" " $2'} | column -t
NAMESPACE    NAME
kube-system  fluentd-cloud-logging-k8s-stclair-minion-wnzd
kube-system  kube-dns-v10-fo6gl
kube-system  kube-proxy-k8s-stclair-minion-wnzd
...

Alternatively, you could use the go-template output of kubectl to create a custom output (which you could also pair with column), e.g. to print pod names and the first 8 characters of the UID:

$ kubectl get pods --all-namespaces -o=go-template="{{println "NAME UID"}}{{range .items}}{{.metadata.name}} {{printf "%.8s\n" .metadata.uid}}{{end}}" | column -t
NAME                                           UID
fluentd-cloud-logging-k8s-stclair-minion-wnzd  8bcb7129
kube-dns-v10-fo6gl                             90bce35e
kube-proxy-k8s-stclair-minion-wnzd             8bc752c8
kubernetes-dashboard-v0.1.0-cptxn              90d18852
l7-lb-controller-v0.5.2-n6i23                  90daf833

More on go-templates here. A variant of JSONpath is also supported.

Read more here: Source link