@@ -32,20 +32,20 @@ of Containers for each.
32
32
在本练习中,你将使用 kubectl 来获取集群中运行的所有 Pod,并格式化输出来提取每个 Pod 中的容器列表。
33
33
34
34
<!--
35
- ## List all Containers in all namespaces
35
+ ## List all Container images in all namespaces
36
36
37
37
- Fetch all Pods in all namespaces using `kubectl get pods --all-namespaces`
38
38
- Format the output to include only the list of Container image names
39
39
using `-o jsonpath={.items[*].spec.containers[*].image}`. This will recursively parse out the
40
40
`image` field from the returned json.
41
- - See the [jsonpath reference](/docs/user-guide /jsonpath/)
41
+ - See the [jsonpath reference](/docs/reference/kubectl /jsonpath/)
42
42
for further information on how to use jsonpath.
43
43
- Format the output using standard tools: `tr`, `sort`, `uniq`
44
44
- Use `tr` to replace spaces with newlines
45
45
- Use `sort` to sort the results
46
46
- Use `uniq` to aggregate image counts
47
47
-->
48
- ## 列出所有命名空间下的所有容器
48
+ ## 列出所有命名空间下的所有容器镜像
49
49
50
50
- 使用 ` kubectl get pods --all-namespaces ` 获取所有命名空间下的所有 Pod
51
51
- 使用 ` -o jsonpath={.items[*].spec.containers[*].image} ` 来格式化输出,以仅包含容器镜像名称。
@@ -80,7 +80,7 @@ jsonpath 解释如下:
80
80
- ` .image ` : 获取镜像
81
81
82
82
<!--
83
- When fetching a single Pod by name, e.g. `kubectl get pod nginx`,
83
+ When fetching a single Pod by name, for example `kubectl get pod nginx`,
84
84
the `.items[*]` portion of the path should be omitted because a single
85
85
Pod is returned instead of a list of items.
86
86
-->
@@ -105,12 +105,12 @@ sort
105
105
```
106
106
107
107
<!--
108
- ## List Containers filtering by Pod label
108
+ ## List Container images filtering by Pod label
109
109
110
110
To target only Pods matching a specific label, use the -l flag. The
111
111
following matches only Pods with labels matching `app=nginx`.
112
112
-->
113
- ## 列出以标签过滤后的 Pod 的所有容器
113
+ ## 列出以标签过滤后的 Pod 的所有容器镜像
114
114
115
115
要获取匹配特定标签的 Pod,请使用 -l 参数。以下匹配仅与标签 ` app=nginx ` 相符的 Pod。
116
116
@@ -119,12 +119,12 @@ kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].ima
119
119
```
120
120
121
121
<!--
122
- ## List Containers filtering by Pod namespace
122
+ ## List Container images filtering by Pod namespace
123
123
124
124
To target only pods in a specific namespace, use the namespace flag. The
125
125
following matches only Pods in the `kube-system` namespace.
126
126
-->
127
- ## 列出以命名空间过滤后的 Pod 的所有容器
127
+ ## 列出以命名空间过滤后的 Pod 的所有容器镜像
128
128
129
129
要获取匹配特定命名空间的 Pod,请使用 namespace 参数。以下仅匹配 ` kube-system ` 命名空间下的 Pod。
130
130
@@ -133,12 +133,12 @@ kubectl get pods --namespace kube-system -o jsonpath="{.items[*].spec.containers
133
133
```
134
134
135
135
<!--
136
- ## List Containers using a go-template instead of jsonpath
136
+ ## List Container images using a go-template instead of jsonpath
137
137
138
138
As an alternative to jsonpath, Kubectl supports using [go-templates](https://golang.org/pkg/text/template/)
139
139
for formatting the output:
140
140
-->
141
- ## 使用 go-template 代替 jsonpath 来获取容器
141
+ ## 使用 go-template 代替 jsonpath 来获取容器镜像
142
142
143
143
作为 jsonpath 的替代,Kubectl 支持使用 [ go-templates] ( https://golang.org/pkg/text/template/ ) 来格式化输出:
144
144
0 commit comments