Skip to content

Commit 96f27ce

Browse files
authored
Merge pull request #34603 from tengqm/zh-resync-staticpod
[zh-cn] Resync static-pod page
2 parents 6a4dd34 + e6b2c53 commit 96f27ce

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

content/zh-cn/docs/tasks/configure-pod-container/static-pod.md

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ without the {{< glossary_tooltip text="API server" term_id="kube-apiserver" >}}
1212
observing them.
1313
Unlike Pods that are managed by the control plane (for example, a
1414
{{< 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).
1616
-->
1717

18-
*静态 Pod* 在指定的节点上由 kubelet 守护进程直接管理,不需要
18+
**静态 Pod** 在指定的节点上由 kubelet 守护进程直接管理,不需要
1919
{{< glossary_tooltip text="API 服务器" term_id="kube-apiserver" >}} 监管。
2020
与由控制面管理的 Pod(例如,{{< glossary_tooltip text="Deployment" term_id="deployment" >}})
21-
不同;kubelet 监视每个静态 Pod(在它崩溃之后重新启动)。
21+
不同;kubelet 监视每个静态 Pod(在它失败之后重新启动)。
2222

2323
<!--
2424
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.
2828
This means that the Pods running on a node are visible on the API server,
2929
but cannot be controlled from there.
3030
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 名称将把以连字符开头的节点主机名作为后缀。
3138

3239
{{< note >}}
40+
<!--
3341
If you are running clustered Kubernetes and are using static
3442
Pods to run a Pod on every node, you should probably be using a
3543
{{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}}
3644
instead.
37-
{{< /note >}}
3845
-->
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 >}}
4746
如果你在运行一个 Kubernetes 集群,并且在每个节点上都运行一个静态 Pod,
48-
就可能需要考虑使用 {{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}} 替代这种方式。
47+
就可能需要考虑使用 {{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}}
48+
替代这种方式。
4949
{{< /note >}}
5050

51+
52+
{{< note >}}
5153
<!--
5254
The `spec` of a static Pod cannot refer to other API objects
5355
(e.g., {{< glossary_tooltip text="ServiceAccount" term_id="service-account" >}},
5456
{{< glossary_tooltip text="ConfigMap" term_id="configmap" >}},
5557
{{< glossary_tooltip text="Secret" term_id="secret" >}}, etc).
5658
-->
57-
58-
{{< note >}}
5959
静态 Pod 的 `spec` 不能引用其他 API 对象
6060
(如:{{< glossary_tooltip text="ServiceAccount" term_id="service-account" >}}、
6161
{{< 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
8585
## 创建静态 Pod {#static-pod-creation}
8686

8787
可以通过[文件系统上的配置文件](/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)
8989
来配置静态 Pod。
9090

9191
<!--
@@ -111,7 +111,6 @@ For example, this is how to start a simple web server as a static Pod:
111111
<!--
112112
1. Choose a node where you want to run the static Pod. In this example, it's `my-node1`.
113113
-->
114-
115114
1. 选择一个要运行静态 Pod 的节点。在这个例子中选择 `my-node1`
116115

117116
```shell
@@ -140,13 +139,13 @@ For example, this is how to start a simple web server as a static Pod:
140139
protocol: TCP
141140
EOF
142141
-->
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`
145144

146145
```shell
147146
# 在 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
150149
apiVersion: v1
151150
kind: Pod
152151
metadata:
@@ -165,20 +164,19 @@ For example, this is how to start a simple web server as a static Pod:
165164
```
166165
167166
<!--
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:
175168
-->
176169
3. 配置这个节点上的 kubelet,使用这个参数执行 `--pod-manifest-path=/etc/kubelet.d/`
177-
在 Fedora 上编辑 `/etc/kubernetes/kubelet` 以包含下行
170+
在 Fedora 上编辑 `/etc/kubernetes/kubelet` 以包含下面这行
178171
179172
```
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/"
181174
```
175+
176+
<!--
177+
or add the `staticPodPath: <the directory>` field in the
178+
[kubelet configuration file](/docs/reference/config-api/kubelet-config.v1beta1/).
179+
-->
182180
或者在 [Kubelet 配置文件](/zh-cn/docs/reference/config-api/kubelet-config.v1beta1/)
183181
中添加 `staticPodPath: <目录>`字段。
184182
@@ -190,7 +188,7 @@ For example, this is how to start a simple web server as a static Pod:
190188
systemctl restart kubelet
191189
```
192190
-->
193-
4. 重启 kubelet。Fedora 上使用下面的命令
191+
4. 重启 kubelet。Fedora 上,你将使用下面的命令
194192
195193
```shell
196194
# 在 kubelet 运行的节点上执行以下命令
@@ -248,6 +246,7 @@ JSON/YAML 格式的 Pod 定义文件。
248246
```
249247
KUBELET_ARGS="--cluster-dns=10.254.0.10 --cluster-domain=kube.local --manifest-url=<manifest-url>"
250248
```
249+
251250
<!--
252251
3. Restart the kubelet. On Fedora, you would run:
253252
@@ -256,7 +255,7 @@ JSON/YAML 格式的 Pod 定义文件。
256255
systemctl restart kubelet
257256
```
258257
-->
259-
3. 重启 kubelet。在 Fedora 上运行如下命令
258+
3. 重启 kubelet。在 Fedora 上,你将运行如下命令
260259
261260
```shell
262261
# 在 kubelet 运行的节点上执行以下命令
@@ -278,7 +277,7 @@ crictl ps
278277
279278
The output might be something like:
280279
-->
281-
## 观察静态 pod 的行为 {#behavior-of-static-pods}
280+
## 观察静态 Pod 的行为 {#behavior-of-static-pods}
282281
283282
当 kubelet 启动时,会自动启动所有定义的静态 Pod。
284283
当定义了一个静态 Pod 并重新启动 kubelet 时,新的静态 Pod 就应该已经在运行了。
@@ -300,12 +299,12 @@ CONTAINER IMAGE CREATED STATE
300299
129fd7d382018 docker.io/library/nginx@sha256:... 11 minutes ago Running web 0 34533c6729106
301300
```
302301
302+
{{< note >}}
303303
<!--
304304
`crictl` outputs the image URI and SHA-256 checksum. `NAME` will look more like:
305305
`docker.io/library/nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31`.
306306
-->
307-
{{< note >}}
308-
`crictl` 会输出镜像 URI 和 SHA-256 校验和。 `NAME` 看起来像:
307+
`crictl` 会输出镜像 URI 和 SHA-256 校验和。`NAME` 看起来像:
309308
`docker.io/library/nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31`
310309
{{< /note >}}
311310
@@ -323,32 +322,34 @@ NAME READY STATUS RESTARTS AGE
323322
static-web 1/1 Running 0 2m
324323
```
325324
325+
{{< note >}}
326326
<!--
327327
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
328328
[Pod Security admission](/docs/concepts/security/pod-security-admission) and [PodSecurityPolicy](/docs/concepts/security/pod-security-policy/).
329329
-->
330-
{{< note >}}
331330
要确保 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/)。
333333
{{< /note >}}
334334
335335
<!--
336336
{{< glossary_tooltip term_id="label" text="Labels" >}} from the static Pod are
337337
propagated into the mirror Pod. You can use those labels as normal via
338338
{{< glossary_tooltip term_id="selector" text="selectors" >}}, etc.
339339
-->
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="选择算符" >}}使用这些标签。
342342
343343
<!--
344344
If you try to use `kubectl` to delete the mirror Pod from the API server,
345345
the kubelet _doesn't_ remove the static Pod:
346346
-->
347-
如果你用 `kubectl` 从 API 服务上删除镜像 Pod,kubelet _不会_ 移除静态 Pod:
347+
如果你用 `kubectl` 从 API 服务上删除镜像 Pod,kubelet **不会**移除静态 Pod:
348348
349349
```shell
350350
kubectl delete pod static-web
351351
```
352+
352353
```
353354
pod "static-web" deleted
354355
```
@@ -379,7 +380,7 @@ sleep 20
379380
crictl ps
380381
```
381382
-->
382-
回到 kubelet 运行的节点上,你可以手动停止容器。
383+
回到 kubelet 运行所在的节点上,你可以手动停止容器。
383384
可以看到过了一段时间后 kubelet 会发现容器停止了并且会自动重启 Pod:
384385
385386
```shell
@@ -398,8 +399,14 @@ CONTAINER IMAGE CREATED STATE
398399
<!--
399400
## Dynamic addition and removal of static pods
400401
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。
402408
409+
<!--
403410
```shell
404411
# This assumes you are using filesystem-hosted static Pod configuration
405412
# Run these commands on the node where the kubelet is running
@@ -413,13 +420,8 @@ sleep 20
413420
crictl ps
414421
```
415422
-->
416-
## 动态增加和删除静态 pod
417-
418-
运行中的 kubelet 会定期扫描配置的目录(比如例子中的 `/etc/kubelet.d` 目录)中的变化,
419-
并且根据文件中出现/消失的 Pod 来添加/删除 Pod。
420-
421423
```shell
422-
# 前提是你在用主机文件系统上的静态 Pod 配置文件
424+
# 这里假定你在用主机文件系统上的静态 Pod 配置文件
423425
# 在 kubelet 运行的节点上执行以下命令
424426
mv /etc/kubelet.d/static-web.yaml /tmp
425427
sleep 20
@@ -435,5 +437,3 @@ CONTAINER IMAGE CREATED STATE
435437
f427638871c35 docker.io/library/nginx@sha256:... 19 seconds ago Running web 1 34533c6729106
436438
```
437439
438-
439-

0 commit comments

Comments
 (0)