Skip to content

Commit 4ff6f32

Browse files
authored
Merge pull request #33005 from mengjiao-liu/sync_static_pod
[zh]Sync static-pod file
2 parents 6e5451d + bd0d8b7 commit 4ff6f32

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

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

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The `spec` of a static Pod cannot refer to other API objects
6767
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
6868

6969
<!--
70-
This page assumes you're using {{< glossary_tooltip term_id="docker" >}} to run Pods,
70+
This page assumes you're using {{< glossary_tooltip term_id="cri-o" >}} to run Pods,
7171
and that your nodes are running the Fedora operating system.
7272
Instructions for other distributions or Kubernetes installations may vary.
7373
-->
@@ -273,7 +273,7 @@ already be running.
273273
You can view running containers (including static Pods) by running (on the node):
274274
```shell
275275
# Run this command on the node where kubelet is running
276-
docker ps
276+
crictl ps
277277
```
278278
279279
The output might be something like:
@@ -287,19 +287,28 @@ The output might be something like:
287287
288288
```shell
289289
# 在 kubelet 运行的节点上执行以下命令
290-
docker ps
290+
crictl ps
291291
```
292292
293293
<!--
294294
The output might be something like:
295295
-->
296296
输出可能会像这样:
297297
298-
```
299-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
300-
f6d05272b57e nginx:latest "nginx" 8 minutes ago Up 8 minutes k8s_web.6f802af4_static-web-fk-node1_default_67e24ed9466ba55986d120c867395f3c_378e5f3c
298+
```console
299+
CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID
300+
129fd7d382018 docker.io/library/nginx@sha256:... 11 minutes ago Running web 0 34533c6729106
301301
```
302302
303+
<!--
304+
`crictl` outputs the image URI and SHA-256 checksum. `NAME` will look more like:
305+
`docker.io/library/nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31`.
306+
-->
307+
{{< note >}}
308+
`crictl` 会输出镜像 URI 和 SHA-256 校验和。 `NAME` 看起来像:
309+
`docker.io/library/nginx@sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31`
310+
{{< /note >}}
311+
303312
<!--
304313
You can see the mirror Pod on the API server:
305314
-->
@@ -310,17 +319,17 @@ kubectl get pods
310319
```
311320
312321
```
313-
NAME READY STATUS RESTARTS AGE
314-
static-web-my-node1 1/1 Running 0 2m
322+
NAME READY STATUS RESTARTS AGE
323+
static-web 1/1 Running 0 2m
315324
```
316325
317326
<!--
318327
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
319-
[PodSecurityPolicy](/docs/concepts/policy/pod-security-policy/).
328+
[Pod Security admission](/docs/concepts/security/pod-security-admission) and [PodSecurityPolicy](/docs/concepts/security/pod-security-policy/).
320329
-->
321330
{{< note >}}
322331
要确保 kubelet 在 API 服务上有创建镜像 Pod 的权限。如果没有,创建请求会被 API 服务拒绝。
323-
可以看[Pod安全策略](/zh/docs/concepts/policy/pod-security-policy/)。
332+
可以看 [Pod 安全性准入](/zh/docs/concepts/security/pod-security-admission/)和 [Pod 安全策略](/zh/docs/concepts/security/pod-security-policy/)。
324333
{{< /note >}}
325334
326335
<!--
@@ -338,10 +347,10 @@ the kubelet _doesn't_ remove the static Pod:
338347
如果你用 `kubectl` 从 API 服务上删除镜像 Pod,kubelet _不会_ 移除静态 Pod:
339348
340349
```shell
341-
kubectl delete pod static-web-my-node1
350+
kubectl delete pod static-web
342351
```
343352
```
344-
pod "static-web-my-node1" deleted
353+
pod "static-web" deleted
345354
```
346355
347356
<!--
@@ -354,37 +363,36 @@ kubectl get pods
354363
```
355364
356365
```
357-
NAME READY STATUS RESTARTS AGE
358-
static-web-my-node1 1/1 Running 0 12s
366+
NAME READY STATUS RESTARTS AGE
367+
static-web 1/1 Running 0 4s
359368
```
360369
361370
<!--
362-
Back on your node where the kubelet is running, you can try to stop the Docker
363-
container manually.
371+
Back on your node where the kubelet is running, you can try to stop the container manually.
364372
You'll see that, after a time, the kubelet will notice and will restart the Pod
365373
automatically:
366374
367375
```shell
368376
# Run these commands on the node where the kubelet is running
369-
docker stop f6d05272b57e # replace with the ID of your container
377+
crictl stop 129fd7d382018 # replace with the ID of your container
370378
sleep 20
371-
docker ps
379+
crictl ps
372380
```
373381
-->
374-
回到 kubelet 运行的节点上,可以手工停止 Docker 容器
382+
回到 kubelet 运行的节点上,你可以手动停止容器
375383
可以看到过了一段时间后 kubelet 会发现容器停止了并且会自动重启 Pod:
376384
377385
```shell
378386
# 在 kubelet 运行的节点上执行以下命令
379387
# 把 ID 换为你的容器的 ID
380-
docker stop f6d05272b57e
388+
crictl stop 129fd7d382018
381389
sleep 20
382-
docker ps
390+
crictl ps
383391
```
384392
385-
```
386-
CONTAINER ID IMAGE COMMAND CREATED ...
387-
5b920cbaf8b1 nginx:latest "nginx -g 'daemon of 2 seconds ago ...
393+
```console
394+
CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID
395+
89db4553e1eeb docker.io/library/nginx@sha256:... 19 seconds ago Running web 1 34533c6729106
388396
```
389397
390398
<!--
@@ -398,11 +406,11 @@ The running kubelet periodically scans the configured directory (`/etc/kubelet.d
398406
#
399407
mv /etc/kubelet.d/static-web.yaml /tmp
400408
sleep 20
401-
docker ps
409+
crictl ps
402410
# You see that no nginx container is running
403411
mv /tmp/static-web.yaml /etc/kubelet.d/
404412
sleep 20
405-
docker ps
413+
crictl ps
406414
```
407415
-->
408416
## 动态增加和删除静态 pod
@@ -415,16 +423,17 @@ docker ps
415423
# 在 kubelet 运行的节点上执行以下命令
416424
mv /etc/kubelet.d/static-web.yaml /tmp
417425
sleep 20
418-
docker ps
426+
crictl ps
419427
# 可以看到没有 nginx 容器在运行
420428
mv /tmp/static-web.yaml /etc/kubelet.d/
421429
sleep 20
422-
docker ps
430+
crictl ps
423431
```
424432
433+
```console
434+
CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID
435+
f427638871c35 docker.io/library/nginx@sha256:... 19 seconds ago Running web 1 34533c6729106
425436
```
426-
CONTAINER ID IMAGE COMMAND CREATED ...
427-
e7a62e3427f1 nginx:latest "nginx -g 'daemon of 27 seconds ago
428-
```
437+
429438
430439

0 commit comments

Comments
 (0)