Andres Caro:
Why trying to get InternalIP with custom columns doesn’t work but with jsonpath works fine?
a) with custom-columns:
controlplane $ k get no -o custom-columns=NODE:metadata.name,INTERNAL_IP:status.addresses[?(@.type == "InternalIP")].address
NODE INTERNAL_IP
error: unrecognized identifier InternalIP
b) with jsonpath:
controlplane $ k get no -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.addresses[?(@.type == "InternalIP")].address}{"\n"}{end}'
controlplane 172.17.0.8
node01 172.17.0.9
Pranay:
you need to escape it with “\”
controlplane $ kubectl get no -o custom-columns=NODE:metadata.name,INTERNAL_IP:status.addresses[?(@.type == \"InternalIP\")].address
NODE INTERNAL_IP
k3d-k8s-agent-0 172.19.0.3
k3d-k8s-agent-1 172.19.0.4
k3d-k8s-server-0 172.19.0.2
Andres Caro:
Hey, Pranay thank you so much! that was the thing
Andres Caro:
Another way is quoting the expression:
controlplane $ k get no -o custom-columns=NODE:.metadata.name,'INTERNAL_IP:.status.addresses[?(@.type=="InternalIP")].address'
NODE INTERNAL_IP
controlplane 172.17.0.15
node01 172.17.0.17