Merge pull request #23141 from webmutation/jsonpath-regex-nosupport

Jsonpath regex nosupport
This commit is contained in:
Kubernetes Prow Robot
2020-08-27 15:33:29 -07:00
committed by GitHub
@@ -98,4 +98,16 @@ kubectl get pods -o=jsonpath="{range .items[*]}{.metadata.name}{\"\t\"}{.status.
```
{{< /note >}}
{{< note >}}
JSONPath regular expressions are not supported. If you want to match using regular expressions, you can use a tool such as `jq`.
```shell
# 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'
```
{{< /note >}}