How would you go about counting the NotReady nodes in the cluster and writing that to a file?
Thanks!
How would you go about counting the NotReady nodes in the cluster and writing that to a file?
Thanks!
Hi @milot, you can do this using the json
output and filtering with jq
, for example:
# kubectl does not support regular expressions for JSONpath output
# The following command does not work
kubectl get pods -o jsonpath='{.items[?(@.metadata.name=~/^test$/)].metadata.name}'
# The following command achieves the desired result
kubectl get pods -o json | jq -r '.items[] | select(.metadata.name | test("test-")).spec.containers[].image'
The second command above it’s an example of how to use jsonpath
+ jq
to filter something.
You can find more examples here.
Regards,
Vitor Jr.
KodeKloud Support