Labs – JSON PATH – Kubernetes
part of k8status.json
“containerStatuses”: [
{
“image”: “nginx:alpine”,
“name”: “nginx”,
“ready”: false,
“restartCount”: 4,
“state”: {
“waiting”: {
“reason”: “ContainerCreating”
}
}
},
{
“image”: “redis:alpine”,
“name”: “redis-container”,
“ready”: false,
“restartCount”: 2,
“state”: {
“waiting”: {
“reason”: “ContainerCreating”
}
}
}
],
cat k8status.json | jpath $.status.containerStatuses[?( @.restartCount == 2)].name # this works
but below queries return empty []
cat k8status.json | jpath $.status.containerStatuses[?(@.name == ‘nginx’)].restartCount. # should return me 4.
cat k8status.json | jpath $.status.containerStatuses[?(@.name == ‘redis-container’)].restartCount. # should return me 2
what am i missing?