Add examples for jsonpath

Closes: #4266
pull/6812/head
Qiming Teng 2018-01-02 11:47:18 +08:00
parent 53e05358be
commit 7341f20401
1 changed files with 10 additions and 0 deletions

View File

@ -62,3 +62,13 @@ text | the plain text | kind is {.kind} | kind is List
?() | filter | {.users[?(@.name=="e2e")].user.password} | secret
range, end | iterate list | {range .items[*]}[{.metadata.name}, {.status.capacity}] {end} | [127.0.0.1, map[cpu:4]] [127.0.0.2, map[cpu:8]]
"" | quote interpreted string | {range .items[*]}{.metadata.name}{"\t"}{end} | 127.0.0.1 127.0.0.2
Below are some examples using jsonpath:
```shell
$ kubectl get pods -o json
$ kubectl get pods -o=jsonpath='{@}'
$ kubectl get pods -o=jsonpath='{.items[0]}'
$ kubectl get pods -o=jsonpath='{.items[0].metadata.name}'
$ kubectl get pods -o=jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.startTime}{"\n"}{end}'
```