kubectl: Use custom-columns output with maps kubectl: Use custom-columns output with maps kubernetes kubernetes

kubectl: Use custom-columns output with maps


Okay, I figured this out. It's easier than I thought.

Annotations is a standard JSON element when it's returned. The problem is that kubectl's JSONPath parser has problems with dots in elements, so you just have to escape them. Here's an example:

kubectl get pvc -o custom-columns=NAME:.metadata.name,"ANNOTATIONS":".metadata.annotations.pv\.kubernetes\.io/bind-completed" -n monitoringNAME                                 ANNOTATIONSprometheus-k8s-db-prometheus-k8s-0   yesprometheus-k8s-db-prometheus-k8s-1   yes