@@ -12,13 +12,13 @@ without the {{< glossary_tooltip text="API server" term_id="kube-apiserver" >}}
12
12
observing them.
13
13
Unlike Pods that are managed by the control plane (for example, a
14
14
{{< glossary_tooltip text="Deployment" term_id="deployment" >}});
15
- instead, the kubelet watches each static Pod (and restarts it if it crashes ).
15
+ instead, the kubelet watches each static Pod (and restarts it if it fails ).
16
16
-->
17
17
18
- * 静态 Pod* 在指定的节点上由 kubelet 守护进程直接管理,不需要
18
+ ** 静态 Pod* * 在指定的节点上由 kubelet 守护进程直接管理,不需要
19
19
{{< glossary_tooltip text="API 服务器" term_id="kube-apiserver" >}} 监管。
20
20
与由控制面管理的 Pod(例如,{{< glossary_tooltip text="Deployment" term_id="deployment" >}})
21
- 不同;kubelet 监视每个静态 Pod(在它崩溃之后重新启动 )。
21
+ 不同;kubelet 监视每个静态 Pod(在它失败之后重新启动 )。
22
22
23
23
<!--
24
24
Static Pods are always bound to one {{< glossary_tooltip term_id="kubelet" >}} on a specific node.
@@ -28,34 +28,34 @@ on the Kubernetes API server for each static Pod.
28
28
This means that the Pods running on a node are visible on the API server,
29
29
but cannot be controlled from there.
30
30
The Pod names will be suffixed with the node hostname with a leading hyphen.
31
+ -->
32
+ 静态 Pod 始终都会绑定到特定节点的 {{< glossary_tooltip term_id="kubelet" >}} 上。
33
+
34
+ kubelet 会尝试通过 Kubernetes API 服务器为每个静态 Pod
35
+ 自动创建一个{{< glossary_tooltip text="镜像 Pod" term_id="mirror-pod" >}}。
36
+ 这意味着节点上运行的静态 Pod 对 API 服务来说是可见的,但是不能通过 API 服务器来控制。
37
+ Pod 名称将把以连字符开头的节点主机名作为后缀。
31
38
32
39
{{< note >}}
40
+ <!--
33
41
If you are running clustered Kubernetes and are using static
34
42
Pods to run a Pod on every node, you should probably be using a
35
43
{{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}}
36
44
instead.
37
- {{< /note >}}
38
45
-->
39
- 静态 Pod 永远都会绑定到一个指定节点上的 {{< glossary_tooltip term_id="kubelet" >}}。
40
-
41
- kubelet 会尝试通过 Kubernetes API 服务器为每个静态 Pod 自动创建一个
42
- {{< glossary_tooltip text="镜像 Pod" term_id="mirror-pod" >}}。
43
- 这意味着节点上运行的静态 Pod 对 API 服务来说是可见的,但是不能通过 API 服务器来控制。
44
- Pod 名称将把以连字符开头的节点主机名作为后缀。
45
-
46
- {{< note >}}
47
46
如果你在运行一个 Kubernetes 集群,并且在每个节点上都运行一个静态 Pod,
48
- 就可能需要考虑使用 {{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}} 替代这种方式。
47
+ 就可能需要考虑使用 {{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}}
48
+ 替代这种方式。
49
49
{{< /note >}}
50
50
51
+
52
+ {{< note >}}
51
53
<!--
52
54
The `spec` of a static Pod cannot refer to other API objects
53
55
(e.g., {{< glossary_tooltip text="ServiceAccount" term_id="service-account" >}},
54
56
{{< glossary_tooltip text="ConfigMap" term_id="configmap" >}},
55
57
{{< glossary_tooltip text="Secret" term_id="secret" >}}, etc).
56
58
-->
57
-
58
- {{< note >}}
59
59
静态 Pod 的 ` spec ` 不能引用其他 API 对象
60
60
(如:{{< glossary_tooltip text="ServiceAccount" term_id="service-account" >}}、
61
61
{{< glossary_tooltip text="ConfigMap" term_id="configmap" >}}、
@@ -85,7 +85,7 @@ You can configure a static Pod with either a [file system hosted configuration f
85
85
## 创建静态 Pod {#static-pod-creation}
86
86
87
87
可以通过[ 文件系统上的配置文件] ( /zh-cn/docs/tasks/configure-pod-container/static-pod/#configuration-files )
88
- 或者 [ web 网络上的配置文件] ( /zh-cn/docs/tasks/configure-pod-container/static-pod/#pods-created-via-http )
88
+ 或者 [ Web 网络上的配置文件] ( /zh-cn/docs/tasks/configure-pod-container/static-pod/#pods-created-via-http )
89
89
来配置静态 Pod。
90
90
91
91
<!--
@@ -111,7 +111,6 @@ For example, this is how to start a simple web server as a static Pod:
111
111
<!--
112
112
1. Choose a node where you want to run the static Pod. In this example, it's `my-node1`.
113
113
-->
114
-
115
114
1 . 选择一个要运行静态 Pod 的节点。在这个例子中选择 ` my-node1 ` 。
116
115
117
116
``` shell
@@ -140,13 +139,13 @@ For example, this is how to start a simple web server as a static Pod:
140
139
protocol: TCP
141
140
EOF
142
141
-->
143
- 2 . 选择一个目录,比如在 ` /etc/kubelet.d ` 目录来保存 web 服务 Pod 的定义文件,
144
- ` /etc/kubelet.d /static-web.yaml ` :
142
+ 2 . 选择一个目录,比如在 ` /etc/kubernetes/manifests ` 目录来保存 Web 服务 Pod 的定义文件,例如
143
+ ` /etc/kubernetes/manifests /static-web.yaml ` :
145
144
146
145
``` shell
147
146
# 在 kubelet 运行的节点上执行以下命令
148
- mkdir /etc/kubelet.d /
149
- cat << EOF >/etc/kubelet.d /static-web.yaml
147
+ mkdir -p /etc/kubernetes/manifests /
148
+ cat << EOF >/etc/kubernetes/manifests /static-web.yaml
150
149
apiVersion: v1
151
150
kind: Pod
152
151
metadata:
@@ -165,20 +164,19 @@ For example, this is how to start a simple web server as a static Pod:
165
164
` ` `
166
165
167
166
< ! --
168
- 3. Configure your kubelet on the node to use this directory by running it with ` --pod-manifest-path=/etc/kubelet.d/` argument. On Fedora edit ` /etc/kubernetes/kubelet` to include this line:
169
-
170
- ` ` `
171
- KUBELET_ARGS="--cluster-dns=10.254.0.10 --cluster-domain=kube.local --pod-manifest-path=/etc/kubelet.d/"
172
- ` ` `
173
- or add the ` staticPodPath: <the directory>` field in the
174
- [kubelet configuration file](/docs/reference/config-api/kubelet-config.v1beta1/).
167
+ 3. Configure your kubelet on the node to use this directory by running it with ` --pod-manifest-path=/etc/kubernetes/manifests/` argument. On Fedora edit ` /etc/kubernetes/kubelet` to include this line:
175
168
-->
176
169
3. 配置这个节点上的 kubelet,使用这个参数执行 ` --pod-manifest-path=/etc/kubelet.d/` 。
177
- 在 Fedora 上编辑 ` /etc/kubernetes/kubelet` 以包含下行 :
170
+ 在 Fedora 上编辑 ` /etc/kubernetes/kubelet` 以包含下面这行 :
178
171
179
172
` ` `
180
- KUBELET_ARGS="--cluster-dns=10.254.0.10 --cluster-domain=kube.local --pod-manifest-path=/etc/kubelet.d /"
173
+ KUBELET_ARGS="--cluster-dns=10.254.0.10 --cluster-domain=kube.local --pod-manifest-path=/etc/kubernetes/manifests /"
181
174
` ` `
175
+
176
+ < ! --
177
+ or add the ` staticPodPath: <the directory>` field in the
178
+ [kubelet configuration file](/docs/reference/config-api/kubelet-config.v1beta1/).
179
+ -->
182
180
或者在 [Kubelet 配置文件](/zh-cn/docs/reference/config-api/kubelet-config.v1beta1/)
183
181
中添加 ` staticPodPath: <目录>` 字段。
184
182
@@ -190,7 +188,7 @@ For example, this is how to start a simple web server as a static Pod:
190
188
systemctl restart kubelet
191
189
` ` `
192
190
-->
193
- 4. 重启 kubelet。Fedora 上使用下面的命令 :
191
+ 4. 重启 kubelet。在 Fedora 上,你将使用下面的命令 :
194
192
195
193
` ` ` shell
196
194
# 在 kubelet 运行的节点上执行以下命令
@@ -248,6 +246,7 @@ JSON/YAML 格式的 Pod 定义文件。
248
246
` ` `
249
247
KUBELET_ARGS=" --cluster-dns=10.254.0.10 --cluster-domain=kube.local --manifest-url=<manifest-url>"
250
248
` ` `
249
+
251
250
< ! --
252
251
3. Restart the kubelet. On Fedora, you would run:
253
252
@@ -256,7 +255,7 @@ JSON/YAML 格式的 Pod 定义文件。
256
255
systemctl restart kubelet
257
256
` ` `
258
257
-->
259
- 3. 重启 kubelet。在 Fedora 上运行如下命令 :
258
+ 3. 重启 kubelet。在 Fedora 上,你将运行如下命令 :
260
259
261
260
` ` ` shell
262
261
# 在 kubelet 运行的节点上执行以下命令
@@ -278,7 +277,7 @@ crictl ps
278
277
279
278
The output might be something like:
280
279
-->
281
- # # 观察静态 pod 的行为 {#behavior-of-static-pods}
280
+ # # 观察静态 Pod 的行为 {#behavior-of-static-pods}
282
281
283
282
当 kubelet 启动时,会自动启动所有定义的静态 Pod。
284
283
当定义了一个静态 Pod 并重新启动 kubelet 时,新的静态 Pod 就应该已经在运行了。
@@ -300,12 +299,12 @@ CONTAINER IMAGE CREATED STATE
300
299
129fd7d382018 docker.io/library/nginx@sha256:... 11 minutes ago Running web 0 34533c6729106
301
300
` ` `
302
301
302
+ {{< note > }}
303
303
< ! --
304
304
` crictl` outputs the image URI and SHA-256 checksum. ` NAME` will look more like:
305
305
` docker.io/library/nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31` .
306
306
-->
307
- {{< note > }}
308
- ` crictl` 会输出镜像 URI 和 SHA-256 校验和。 ` NAME` 看起来像:
307
+ ` crictl` 会输出镜像 URI 和 SHA-256 校验和。` NAME` 看起来像:
309
308
` docker.io/library/nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31` 。
310
309
{{< /note > }}
311
310
@@ -323,32 +322,34 @@ NAME READY STATUS RESTARTS AGE
323
322
static-web 1/1 Running 0 2m
324
323
` ` `
325
324
325
+ {{< note > }}
326
326
< ! --
327
327
Make sure the kubelet has permission to create the mirror Pod in the API server. If not, the creation request is rejected by the API server. See
328
328
[Pod Security admission](/docs/concepts/security/pod-security-admission) and [PodSecurityPolicy](/docs/concepts/security/pod-security-policy/).
329
329
-->
330
- {{< note > }}
331
330
要确保 kubelet 在 API 服务上有创建镜像 Pod 的权限。如果没有,创建请求会被 API 服务拒绝。
332
- 可以看 [Pod 安全性准入](/zh-cn/docs/concepts/security/pod-security-admission/)和 [Pod 安全策略](/zh-cn/docs/concepts/security/pod-security-policy/)。
331
+ 参阅 [Pod 安全性准入](/zh-cn/docs/concepts/security/pod-security-admission/)和
332
+ [Pod 安全策略](/zh-cn/docs/concepts/security/pod-security-policy/)。
333
333
{{< /note > }}
334
334
335
335
< ! --
336
336
{{< glossary_tooltip term_id=" label" text=" Labels" > }} from the static Pod are
337
337
propagated into the mirror Pod. You can use those labels as normal via
338
338
{{< glossary_tooltip term_id=" selector" text=" selectors" > }}, etc.
339
339
-->
340
- 静态 Pod 上的{{< glossary_tooltip term_id=" label" text=" 标签" > }} 被传到镜像 Pod。
341
- 你可以通过 {{< glossary_tooltip term_id=" selector" text=" 选择算符" > }} 使用这些标签。
340
+ 静态 Pod 上的{{< glossary_tooltip term_id=" label" text=" 标签" > }}被传播到镜像 Pod。
341
+ 你可以通过{{< glossary_tooltip term_id=" selector" text=" 选择算符" > }}使用这些标签。
342
342
343
343
< ! --
344
344
If you try to use ` kubectl` to delete the mirror Pod from the API server,
345
345
the kubelet _doesn' t_ remove the static Pod:
346
346
-->
347
- 如果你用 `kubectl` 从 API 服务上删除镜像 Pod,kubelet _不会_ 移除静态 Pod:
347
+ 如果你用 `kubectl` 从 API 服务上删除镜像 Pod,kubelet **不会** 移除静态 Pod:
348
348
349
349
```shell
350
350
kubectl delete pod static-web
351
351
```
352
+
352
353
```
353
354
pod "static-web" deleted
354
355
```
@@ -379,7 +380,7 @@ sleep 20
379
380
crictl ps
380
381
` ` `
381
382
-->
382
- 回到 kubelet 运行的节点上 ,你可以手动停止容器。
383
+ 回到 kubelet 运行所在的节点上 ,你可以手动停止容器。
383
384
可以看到过了一段时间后 kubelet 会发现容器停止了并且会自动重启 Pod:
384
385
385
386
` ` ` shell
@@ -398,8 +399,14 @@ CONTAINER IMAGE CREATED STATE
398
399
< ! --
399
400
# # Dynamic addition and removal of static pods
400
401
401
- The running kubelet periodically scans the configured directory (` /etc/kubelet.d` in our example) for changes and adds/removes Pods as files appear/disappear in this directory.
402
+ The running kubelet periodically scans the configured directory (` /etc/kubernetes/manifests` in our example) for changes and adds/removes Pods as files appear/disappear in this directory.
403
+ -->
404
+ # # 动态增加和删除静态 Pod
405
+
406
+ 运行中的 kubelet 会定期扫描配置的目录(比如例子中的 ` /etc/kubernetes/manifests` 目录)中的变化,
407
+ 并且根据文件中出现/消失的 Pod 来添加/删除 Pod。
402
408
409
+ < ! --
403
410
` ` ` shell
404
411
# This assumes you are using filesystem-hosted static Pod configuration
405
412
# Run these commands on the node where the kubelet is running
@@ -413,13 +420,8 @@ sleep 20
413
420
crictl ps
414
421
` ` `
415
422
-->
416
- # # 动态增加和删除静态 pod
417
-
418
- 运行中的 kubelet 会定期扫描配置的目录(比如例子中的 ` /etc/kubelet.d` 目录)中的变化,
419
- 并且根据文件中出现/消失的 Pod 来添加/删除 Pod。
420
-
421
423
` ` ` shell
422
- # 前提是你在用主机文件系统上的静态 Pod 配置文件
424
+ # 这里假定你在用主机文件系统上的静态 Pod 配置文件
423
425
# 在 kubelet 运行的节点上执行以下命令
424
426
mv /etc/kubelet.d/static-web.yaml /tmp
425
427
sleep 20
@@ -435,5 +437,3 @@ CONTAINER IMAGE CREATED STATE
435
437
f427638871c35 docker.io/library/nginx@sha256:... 19 seconds ago Running web 1 34533c6729106
436
438
` ` `
437
439
438
-
439
-
0 commit comments