@@ -4,14 +4,6 @@ title: "Kubernetes 的取证容器检查点"
4
4
date : 2022-12-05
5
5
slug : forensic-container-checkpointing-alpha
6
6
---
7
- <!--
8
- ---
9
- layout: blog
10
- title: "Forensic container checkpointing in Kubernetes"
11
- date: 2022-12-05
12
- slug: forensic-container-checkpointing-alpha
13
- ---
14
- -->
15
7
16
8
** 作者:** [ Adrian Reber] ( https://github.com/adrianreber ) (Red Hat)
17
9
<!--
@@ -84,8 +76,8 @@ The feature is behind a [feature gate][container-checkpoint-feature-gate], so
84
76
make sure to enable the `ContainerCheckpoint` gate before you can use the new
85
77
feature.
86
78
-->
87
-
88
- 该功能在 [ 特性门 ] [ container-checkpoint-feature-gate ] 后面,因此在使用新功能之前, 请确保启用了 ContainerCheckpoint 特性门 。
79
+ 该功能在 [ 特性门控 ] [ container-checkpoint-feature-gate ] 后面,因此在使用这个新功能之前,
80
+ 请确保启用了 ContainerCheckpoint 特性门控 。
89
81
90
82
<!--
91
83
The runtime must also support container checkpointing:
@@ -115,7 +107,8 @@ is also necessary to install CRIU. Usually runc or crun depend on CRIU and
115
107
therefore it is installed automatically.
116
108
-->
117
109
要将取证容器检查点与 CRI-O 结合使用,需要使用命令行选项--enable-criu-support=true 启动运行时。
118
- Kubernetes 方面,你需要在启用 ContainerCheckpoint 特性门的情况下运行你的集群。由于检查点功能是由 CRIU 提供的,因此也有必要安装 CRIU。
110
+ Kubernetes 方面,你需要在启用 ContainerCheckpoint 特性门控的情况下运行你的集群。
111
+ 由于检查点功能是由 CRIU 提供的,因此也有必要安装 CRIU。
119
112
通常 runc 或 crun 依赖于 CRIU,因此它是自动安装的。
120
113
121
114
<!--
@@ -151,7 +144,7 @@ For a container named *counter* in a pod named *counters* in a namespace named
151
144
curl -X POST "https://localhost:10250/checkpoint/default/counters/counter"
152
145
```
153
146
-->
154
- 对于名为 ** default** 的命名空间中名为 ** counters** 的 pod 中的名为 ** counter** 的容器, ** kubelet** API 端点可在以下位置访问 :
147
+ 对于 ** default** 命名空间中 ** counters** Pod 中名为 ** counter** 的容器,可通过以下方式访问 ** kubelet** API 端点 :
155
148
156
149
``` shell
157
150
curl -X POST " https://localhost:10250/checkpoint/default/counters/counter"
@@ -166,7 +159,8 @@ use of the *kubelet* `checkpoint` API:
166
159
--insecure --cert /var/run/kubernetes/client-admin.crt --key /var/run/kubernetes/client-admin.key
167
160
```
168
161
-->
169
- 为了完整起见,以下 curl 命令行选项对于让 curl 接受 ** kubelet** 的自签名证书并授权使用 ** kubelet** 检查点 API 是必要的:
162
+ 为了完整起见,以下 ` curl ` 命令行选项对于让 ` curl ` 接受 ** kubelet** 的自签名证书并授权使用
163
+ ** kubelet** 检查点 API 是必要的:
170
164
171
165
``` shell
172
166
--insecure --cert /var/run/kubernetes/client-admin.crt --key /var/run/kubernetes/client-admin.key
@@ -183,8 +177,8 @@ Once the checkpointing has finished the checkpoint should be available at
183
177
184
178
You could then use that tar archive to restore the container somewhere else.
185
179
-->
186
- 触发这个 ** kubelet** API 将从 CRI-O 请求创建一个检查点,CRI-O 从你的低级运行时(例如, runc)请求一个检查点。
187
- 看到这个请求,runc 调用 criu 工具来执行实际的检查点操作。
180
+ 触发这个 ** kubelet** API 将从 CRI-O 请求创建一个检查点,CRI-O 从你的低级运行时(例如 ` runc ` )请求一个检查点。
181
+ 看到这个请求,` runc ` 调用 ` criu ` 工具来执行实际的检查点操作。
188
182
189
183
检查点操作完成后,检查点应该位于
190
184
` /var/lib/kubelet/checkpoints/checkpoint-<pod-name>_<namespace-name>-<container-name>-<timestamp>.tar `
@@ -204,9 +198,9 @@ during restore, I recommend that you use the latest version of CRI-O from the
204
198
manually create certain directories Kubernetes would create before starting the
205
199
container.
206
200
-->
207
- 使用检查点 tar 归档文件,可以在 Kubernetes 之外的 CRI-O 沙箱实例中恢复容器。为了在恢复过程中获得更好的用户体验,我建议你使用 CRI-O GitHub 的 ** main** 分支中最新版本的 CRI-O。
201
+ 使用检查点 tar 归档文件,可以在 Kubernetes 之外的 CRI-O 沙箱实例中恢复容器。
202
+ 为了在恢复过程中获得更好的用户体验,建议你使用 CRI-O GitHub 的 ** main** 分支中最新版本的 CRI-O。
208
203
如果你使用的是 CRI-O v1.25,你需要在启动容器之前手动创建 Kubernetes 会创建的某些目录。
209
-
210
204
<!--
211
205
The first step to restore a container outside of Kubernetes is to create a pod sandbox
212
206
using *crictl*:
@@ -347,7 +341,8 @@ spec:
347
341
nodeName: <destination-node>
348
342
```
349
343
-->
350
- 要恢复此检查点镜像(container-image-registry.example/user/checkpoint-image: latest ),该镜像需要在 Pod 的规范中列出。下面是一个清单示例:
344
+ 要恢复此检查点镜像(container-image-registry.example/user/checkpoint-image: latest ),
345
+ 该镜像需要在 Pod 的规约中列出。下面是一个清单示例:
351
346
352
347
``` yaml
353
348
apiVersion : v1
@@ -371,7 +366,8 @@ instead of the usual steps to create and start a container,
371
366
CRI-O fetches the checkpoint data and restores the container from that
372
367
specified checkpoint.
373
368
-->
374
- Kubernetes 将新的 Pod 调度到一个节点上。该节点上的 kubelet 指示容器运行时(本例中为 CRI-O)基于指定为 `registry/user/checkpoint-image:latest` 的镜像创建并启动容器。
369
+ Kubernetes 将新的 Pod 调度到一个节点上。该节点上的 kubelet 指示容器运行时(本例中为 CRI-O)
370
+ 基于指定为 `registry/user/checkpoint-image:latest` 的镜像创建并启动容器。
375
371
CRI-O 检测到 `registry/user/checkpoint-image:latest` 是对检查点数据的引用,而不是容器镜像。
376
372
然后,与创建和启动容器的通常步骤不同,CRI-O 获取检查点数据,并从指定的检查点恢复容器。
377
373
@@ -380,7 +376,8 @@ The application in that Pod would continue running as if the checkpoint had not
380
376
within the container, the application looks and behaves like any other container that had been
381
377
started normally and not restored from a checkpoint.
382
378
-->
383
- 该 Pod 中的应用程序将继续运行,就像检查点未被获取一样;在该容器中,应用程序的外观和行为,与正常启动且未从检查点恢复的任何其他容器相似。
379
+ 该 Pod 中的应用程序将继续运行,就像检查点未被获取一样;在该容器中,
380
+ 应用程序的外观和行为,与正常启动且未从检查点恢复的任何其他容器相似。
384
381
385
382
<!--
386
383
With these steps, it is possible to replace a Pod running on one node
0 commit comments