get entire json object via kubectl with filter on field value

17 Views Asked by At

So the following query:

kubectl get mycustomresource -A -o json --field-selector status.state=failed

returns this:

field selector "status.state=failed": field label "status.state" not supported

and there's no way I'm going to be able to change that to be supported.

Question: how do I get the entire json object for all objects where a field is a certain value without using --field-selector?

1

There are 1 best solutions below

0
Rob Evans On

Try using -o jsonpath="{._______}"

Example:

kubectl get mycustomresource -A -o jsonpath=${.status[state='failed']}"

You may need to use some wild cards if your looking for items at the bottom of a json document hierarchy.