kubernetes: JsonPath nested condition and multiple conditions are not working

I want to get the list of all pods that are ready to take requests. In order to do that I run the following queries:

kubectl get pods -l app=my-app -o jsonpath='{.items[?(@.status.conditions[?(@.type == "Ready")].status == "True")].status.phase}'

OR

kubectl get pods -l app=my-app -o jsonpath='{.items[?(@.status.conditions[*].type == "Ready" && @.status.conditions[*].status == "True")].status.phase}'

Neither of them works. Jsonpath doesn’t support nested filters or multiple filters.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 36
  • Comments: 34 (18 by maintainers)

Most upvoted comments

👋 Is this being worked on anywhere? If not I could take a look.

/reopen Issue still there

Seems a new draft was release three days ago: https://datatracker.ietf.org/wg/jsonpath/documents/

Working to get the first part of the implementation merged over at #79227

Looks like there’s one in the process of being drafted: https://tools.ietf.org/html/draft-goessner-dispatch-jsonpath-00