@@ -23,7 +23,7 @@ of Containers for each.
23
23
24
24
- Fetch all Pods in all namespaces using ` kubectl get pods --all-namespaces `
25
25
- Format the output to include only the list of Container image names
26
- using ` -o jsonpath={..image} ` . This will recursively parse out the
26
+ using ` -o jsonpath={.items[*].spec.containers[*] .image} ` . This will recursively parse out the
27
27
` image ` field from the returned json.
28
28
- See the [ jsonpath reference] ( /docs/reference/kubectl/jsonpath/ )
29
29
for further information on how to use jsonpath.
@@ -33,7 +33,7 @@ of Containers for each.
33
33
- Use ` uniq ` to aggregate image counts
34
34
35
35
``` shell
36
- kubectl get pods --all-namespaces -o jsonpath=" {..image}" | \
36
+ kubectl get pods --all-namespaces -o jsonpath=" {.items[*].spec.containers[*] .image}" | \
37
37
tr -s ' [[:space:]]' ' \n' | \
38
38
sort | \
39
39
uniq -c
@@ -80,7 +80,7 @@ To target only Pods matching a specific label, use the -l flag. The
80
80
following matches only Pods with labels matching ` app=nginx ` .
81
81
82
82
``` shell
83
- kubectl get pods --all-namespaces -o=jsonpath=" {..image}" -l app=nginx
83
+ kubectl get pods --all-namespaces -o=jsonpath=" {.items[*].spec.containers[*] .image}" -l app=nginx
84
84
```
85
85
86
86
## List Container images filtering by Pod namespace
@@ -89,7 +89,7 @@ To target only pods in a specific namespace, use the namespace flag. The
89
89
following matches only Pods in the ` kube-system ` namespace.
90
90
91
91
``` shell
92
- kubectl get pods --namespace kube-system -o jsonpath=" {..image}"
92
+ kubectl get pods --namespace kube-system -o jsonpath=" {.items[*].spec.containers[*] .image}"
93
93
```
94
94
95
95
## List Container images using a go-template instead of jsonpath
0 commit comments