Good day, thank you for your time.
I try to extract the custom column value from endpoints to get a name and IP address like this:
kubectl get endpoints -o custom-columns=NAME:.metadata.name,ENDPOINTS:subsets[0].addresses[0][0].ip
but I got no result, trying different combinations of this command.
The Endpoints format:
Name: "mysvc",
Subsets: [
{
Addresses: [{"ip": "10.10.1.1"}, {"ip": "10.10.2.2"}],
Ports: [{"name": "a", "port": 8675}, {"name": "b", "port": 309}]
},
{
Addresses: [{"ip": "10.10.3.3"}],
Ports: [{"name": "a", "port": 93}, {"name": "b", "port": 76}]
},
]
Thank you for your time and attention. Best regards Andrei
IIUC, you want the
metadata.nameand all (!?)ip's?subsetcontains an arrayaddressesso:You can't
addresses[0][0]But you could
addresses[0].ipOr, if you want all of the IPs, you could
addresses[*].ipOr: