3 ms·
But how do you get that '.spec.containers[].ports'? It seems to me that for your example use case, gron is at least useful to first understand the json structu
by monsieurbanana 6y ago
But how do you get that '.spec.containers[].ports'?
It seems to me that for your example use case, gron is at least useful to first understand the json structure before making your jq request. And, for simple use cases like this one, enough to replace jq altogether.
- jrockway 6y agoWell, the schema of the JSON is something you have to come up with on your own. I happen to have seen like 8 trillion pod manifests so I know what I'm looking for, but if you don't, you have to figure out the schema in some other way. To reverse engineer something, I usually pipe into keys (jq keys, jq '.spec | keys', jq '.spec.containers[] | keys', etc.) For Kubernetes specifically, "kubectl explain pod", "kubectl explain pod.spec", etc. will help you find what you're looking for.
- seppel 6y ago> Well, the schema of the JSON is something you have to come up with on your own. I happen to have seen like 8 trillion pod manifests so I know what I'm looking for, but if you don't, you have to figure out the schema in some other way. Well, or you just do kubectl get pod pod -o json | gron | grep port and you will get the answer to the original question + the path.