Skip to content

Commit ea79d52

Browse files
authored
Merge pull request #42858 from windsonsea/statpo
[zh] sync static-pod.md
2 parents 216e238 + cf7333d commit ea79d52

File tree

1 file changed

+36
-17
lines changed

1 file changed

+36
-17
lines changed

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

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ Pod 名称将把以连字符开头的节点主机名作为后缀。
4646
<!--
4747
If you are running clustered Kubernetes and are using static
4848
Pods to run a Pod on every node, you should probably be using a
49-
{{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}}
50-
instead.
49+
{{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}} instead.
5150
-->
5251
如果你在运行一个 Kubernetes 集群,并且在每个节点上都运行一个静态 Pod,
5352
就可能需要考虑使用 {{< glossary_tooltip text="DaemonSet" term_id="daemonset" >}}
@@ -92,7 +91,9 @@ Instructions for other distributions or Kubernetes installations may vary.
9291
<!--
9392
## Create a static pod {#static-pod-creation}
9493
95-
You can configure a static Pod with either a [file system hosted configuration file](/docs/tasks/configure-pod-container/static-pod/#configuration-files) or a [web hosted configuration file](/docs/tasks/configure-pod-container/static-pod/#pods-created-via-http).
94+
You can configure a static Pod with either a
95+
[file system hosted configuration file](/docs/tasks/configure-pod-container/static-pod/#configuration-files)
96+
or a [web hosted configuration file](/docs/tasks/configure-pod-container/static-pod/#pods-created-via-http).
9697
-->
9798
## 创建静态 Pod {#static-pod-creation}
9899

@@ -102,7 +103,8 @@ You can configure a static Pod with either a [file system hosted configuration f
102103
<!--
103104
### Filesystem-hosted static Pod manifest {#configuration-files}
104105
105-
Manifests are standard Pod definitions in JSON or YAML format in a specific directory. Use the `staticPodPath: <the directory>` field in the
106+
Manifests are standard Pod definitions in JSON or YAML format in a specific directory.
107+
Use the `staticPodPath: <the directory>` field in the
106108
[kubelet configuration file](/docs/reference/config-api/kubelet-config.v1beta1/),
107109
which periodically scans the directory and creates/deletes static Pods as YAML/JSON files appear/disappear there.
108110
Note that the kubelet will ignore files starting with dots when scanning the specified directory.
@@ -129,11 +131,15 @@ For example, this is how to start a simple web server as a static Pod:
129131
```
130132

131133
<!--
132-
2. Choose a directory, say `/etc/kubernetes/manifests` and place a web server Pod definition there, for example `/etc/kubernetes/manifests/static-web.yaml`:
134+
1. Choose a directory, say `/etc/kubernetes/manifests` and place a web server
135+
Pod definition there, for example `/etc/kubernetes/manifests/static-web.yaml`:
133136
-->
134137
2. 选择一个目录,比如在 `/etc/kubernetes/manifests` 目录来保存 Web 服务 Pod 的定义文件,例如
135138
`/etc/kubernetes/manifests/static-web.yaml`
136139

140+
<!--
141+
# Run this command on the node where kubelet is running
142+
-->
137143
```shell
138144
# 在 kubelet 运行的节点上执行以下命令
139145
mkdir -p /etc/kubernetes/manifests/
@@ -156,7 +162,9 @@ For example, this is how to start a simple web server as a static Pod:
156162
```
157163
158164
<!--
159-
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:
165+
1. Configure your kubelet on the node to use this directory by running it with
166+
`--pod-manifest-path=/etc/kubernetes/manifests/` argument.
167+
On Fedora, edit `/etc/kubernetes/kubelet` to include this line:
160168
-->
161169
3. 配置这个节点上的 kubelet,使用这个参数执行 `--pod-manifest-path=/etc/kubelet.d/`
162170
在 Fedora 上编辑 `/etc/kubernetes/kubelet` 以包含下面这行:
@@ -173,7 +181,7 @@ For example, this is how to start a simple web server as a static Pod:
173181
`staticPodPath: <目录>`字段。
174182
175183
<!--
176-
4. Restart the kubelet. On Fedora, you would run:
184+
1. Restart the kubelet. On Fedora, you would run:
177185
178186
```shell
179187
# Run this command on the node where the kubelet is running
@@ -230,22 +238,24 @@ JSON/YAML 格式的 Pod 定义文件。
230238
```
231239
232240
<!--
233-
2. Configure the kubelet on your selected node to use this web manifest by running it with `--manifest-url=<manifest-url>`. On Fedora, edit `/etc/kubernetes/kubelet` to include this line:
241+
1. Configure the kubelet on your selected node to use this web manifest by
242+
running it with `--manifest-url=<manifest-url>`.
243+
On Fedora, edit `/etc/kubernetes/kubelet` to include this line:
234244
-->
235245
2. 通过在选择的节点上使用 `--manifest-url=<manifest-url>` 配置运行 kubelet。
236246
在 Fedora 添加下面这行到 `/etc/kubernetes/kubelet`
237247
238-
```
248+
```shell
239249
KUBELET_ARGS="--cluster-dns=10.254.0.10 --cluster-domain=kube.local --manifest-url=<manifest-url>"
240250
```
241251
242252
<!--
243-
3. Restart the kubelet. On Fedora, you would run:
253+
1. Restart the kubelet. On Fedora, you would run:
244254
245-
```shell
246-
# Run this command on the node where the kubelet is running
247-
systemctl restart kubelet
248-
```
255+
```shell
256+
# Run this command on the node where the kubelet is running
257+
systemctl restart kubelet
258+
```
249259
-->
250260
3. 重启 kubelet。在 Fedora 上,你将运行如下命令:
251261
@@ -314,7 +324,8 @@ static-web 1/1 Running 0 2m
314324
315325
{{< note >}}
316326
<!--
317-
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.
327+
Make sure the kubelet has permission to create the mirror Pod in the API server.
328+
If not, the creation request is rejected by the API server.
318329
-->
319330
要确保 kubelet 在 API 服务上有创建镜像 Pod 的权限。如果没有,创建请求会被 API 服务拒绝。
320331
{{< /note >}}
@@ -385,6 +396,11 @@ CONTAINER IMAGE CREATED STATE
385396
386397
<!--
387398
Once you identify the right container, you can get the logs for that container with `crictl`:
399+
400+
```shell
401+
# Run these commands on the node where the container is running
402+
crictl logs <container_id>
403+
```
388404
-->
389405
一旦你找到合适的容器,你就可以使用 `crictl` 获取该容器的日志。
390406
@@ -400,15 +416,18 @@ crictl logs <container_id>
400416
```
401417
402418
<!--
403-
To find more about how to debug using `crictl`, please visit [_Debugging Kubernetes nodes with crictl_](https://kubernetes.io/docs/tasks/debug/debug-cluster/crictl/)
419+
To find more about how to debug using `crictl`, please visit
420+
[_Debugging Kubernetes nodes with crictl_](/docs/tasks/debug/debug-cluster/crictl/).
404421
-->
405422
若要找到如何使用 `crictl` 进行调试的更多信息,
406423
请访问[使用 crictl 对 Kubernetes 节点进行调试](/zh-cn/docs/tasks/debug/debug-cluster/crictl/)。
407424
408425
<!--
409426
## Dynamic addition and removal of static pods
410427
411-
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.
428+
The running kubelet periodically scans the configured directory
429+
(`/etc/kubernetes/manifests` in our example) for changes and
430+
adds/removes Pods as files appear/disappear in this directory.
412431
-->
413432
## 动态增加和删除静态 Pod {#dynamic-addition-and-removal-of-static-pods}
414433

0 commit comments

Comments
 (0)