@@ -67,7 +67,7 @@ The `spec` of a static Pod cannot refer to other API objects
67
67
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
68
68
69
69
<!--
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,
71
71
and that your nodes are running the Fedora operating system.
72
72
Instructions for other distributions or Kubernetes installations may vary.
73
73
-->
@@ -273,7 +273,7 @@ already be running.
273
273
You can view running containers (including static Pods) by running (on the node):
274
274
` ` ` shell
275
275
# Run this command on the node where kubelet is running
276
- docker ps
276
+ crictl ps
277
277
` ` `
278
278
279
279
The output might be something like:
@@ -287,19 +287,28 @@ The output might be something like:
287
287
288
288
` ` ` shell
289
289
# 在 kubelet 运行的节点上执行以下命令
290
- docker ps
290
+ crictl ps
291
291
` ` `
292
292
293
293
< ! --
294
294
The output might be something like:
295
295
-->
296
296
输出可能会像这样:
297
297
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
301
301
` ` `
302
302
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
+
303
312
< ! --
304
313
You can see the mirror Pod on the API server:
305
314
-->
@@ -310,17 +319,17 @@ kubectl get pods
310
319
` ` `
311
320
312
321
` ` `
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
315
324
` ` `
316
325
317
326
< ! --
318
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
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/).
320
329
-->
321
330
{{< note > }}
322
331
要确保 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/)。
324
333
{{< /note > }}
325
334
326
335
< ! --
@@ -338,10 +347,10 @@ the kubelet _doesn't_ remove the static Pod:
338
347
如果你用 `kubectl` 从 API 服务上删除镜像 Pod,kubelet _不会_ 移除静态 Pod:
339
348
340
349
```shell
341
- kubectl delete pod static-web-my-node1
350
+ kubectl delete pod static-web
342
351
```
343
352
```
344
- pod "static-web-my-node1 " deleted
353
+ pod "static-web" deleted
345
354
```
346
355
347
356
<!--
@@ -354,37 +363,36 @@ kubectl get pods
354
363
```
355
364
356
365
```
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
359
368
```
360
369
361
370
<!--
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.
364
372
You' ll see that, after a time, the kubelet will notice and will restart the Pod
365
373
automatically:
366
374
367
375
` ` ` shell
368
376
# 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
370
378
sleep 20
371
- docker ps
379
+ crictl ps
372
380
` ` `
373
381
-->
374
- 回到 kubelet 运行的节点上,可以手工停止 Docker 容器 。
382
+ 回到 kubelet 运行的节点上,你可以手动停止容器 。
375
383
可以看到过了一段时间后 kubelet 会发现容器停止了并且会自动重启 Pod:
376
384
377
385
` ` ` shell
378
386
# 在 kubelet 运行的节点上执行以下命令
379
387
# 把 ID 换为你的容器的 ID
380
- docker stop f6d05272b57e
388
+ crictl stop 129fd7d382018
381
389
sleep 20
382
- docker ps
390
+ crictl ps
383
391
` ` `
384
392
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
388
396
` ` `
389
397
390
398
< ! --
@@ -398,11 +406,11 @@ The running kubelet periodically scans the configured directory (`/etc/kubelet.d
398
406
#
399
407
mv /etc/kubelet.d/static-web.yaml /tmp
400
408
sleep 20
401
- docker ps
409
+ crictl ps
402
410
# You see that no nginx container is running
403
411
mv /tmp/static-web.yaml /etc/kubelet.d/
404
412
sleep 20
405
- docker ps
413
+ crictl ps
406
414
` ` `
407
415
-->
408
416
# # 动态增加和删除静态 pod
@@ -415,16 +423,17 @@ docker ps
415
423
# 在 kubelet 运行的节点上执行以下命令
416
424
mv /etc/kubelet.d/static-web.yaml /tmp
417
425
sleep 20
418
- docker ps
426
+ crictl ps
419
427
# 可以看到没有 nginx 容器在运行
420
428
mv /tmp/static-web.yaml /etc/kubelet.d/
421
429
sleep 20
422
- docker ps
430
+ crictl ps
423
431
` ` `
424
432
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
425
436
` ` `
426
- CONTAINER ID IMAGE COMMAND CREATED ...
427
- e7a62e3427f1 nginx:latest " nginx -g 'daemon of 27 seconds ago
428
- ` ` `
437
+
429
438
430
439
0 commit comments