Skip to content

Commit 5d91372

Browse files
committed
update per windsonsea's comments
1 parent c608681 commit 5d91372

File tree

2 files changed

+41
-29
lines changed
  • content/zh-cn/blog/_posts
    • 2022-12-05-forensic-container-checkpointing
    • 2023-03-10-forensic-container-analysis

2 files changed

+41
-29
lines changed

content/zh-cn/blog/_posts/2022-12-05-forensic-container-checkpointing/index.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ title: "Kubernetes 的取证容器检查点"
44
date: 2022-12-05
55
slug: forensic-container-checkpointing-alpha
66
---
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-
-->
157

168
**作者:** [Adrian Reber](https://github.com/adrianreber) (Red Hat)
179
<!--
@@ -84,8 +76,8 @@ The feature is behind a [feature gate][container-checkpoint-feature-gate], so
8476
make sure to enable the `ContainerCheckpoint` gate before you can use the new
8577
feature.
8678
-->
87-
88-
该功能在[特性门][container-checkpoint-feature-gate]后面,因此在使用新功能之前,请确保启用了 ContainerCheckpoint 特性门
79+
该功能在[特性门控][container-checkpoint-feature-gate]后面,因此在使用这个新功能之前,
80+
请确保启用了 ContainerCheckpoint 特性门控
8981

9082
<!--
9183
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
115107
therefore it is installed automatically.
116108
-->
117109
要将取证容器检查点与 CRI-O 结合使用,需要使用命令行选项--enable-criu-support=true 启动运行时。
118-
Kubernetes 方面,你需要在启用 ContainerCheckpoint 特性门的情况下运行你的集群。由于检查点功能是由 CRIU 提供的,因此也有必要安装 CRIU。
110+
Kubernetes 方面,你需要在启用 ContainerCheckpoint 特性门控的情况下运行你的集群。
111+
由于检查点功能是由 CRIU 提供的,因此也有必要安装 CRIU。
119112
通常 runc 或 crun 依赖于 CRIU,因此它是自动安装的。
120113

121114
<!--
@@ -151,7 +144,7 @@ For a container named *counter* in a pod named *counters* in a namespace named
151144
curl -X POST "https://localhost:10250/checkpoint/default/counters/counter"
152145
```
153146
-->
154-
对于名为 **default** 的命名空间中名为 **counters** 的 pod 中的名为 **counter** 的容器, **kubelet** API 端点可在以下位置访问
147+
对于 **default** 命名空间中 **counters** Pod 中名为 **counter** 的容器,可通过以下方式访问 **kubelet** API 端点
155148

156149
```shell
157150
curl -X POST "https://localhost:10250/checkpoint/default/counters/counter"
@@ -166,7 +159,8 @@ use of the *kubelet* `checkpoint` API:
166159
--insecure --cert /var/run/kubernetes/client-admin.crt --key /var/run/kubernetes/client-admin.key
167160
```
168161
-->
169-
为了完整起见,以下 curl 命令行选项对于让 curl 接受 **kubelet** 的自签名证书并授权使用 **kubelet** 检查点 API 是必要的:
162+
为了完整起见,以下 `curl` 命令行选项对于让 `curl` 接受 **kubelet** 的自签名证书并授权使用
163+
**kubelet** 检查点 API 是必要的:
170164

171165
```shell
172166
--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
183177
184178
You could then use that tar archive to restore the container somewhere else.
185179
-->
186-
触发这个 **kubelet** API 将从 CRI-O 请求创建一个检查点,CRI-O 从你的低级运行时(例如runc)请求一个检查点。
187-
看到这个请求,runc 调用 criu 工具来执行实际的检查点操作。
180+
触发这个 **kubelet** API 将从 CRI-O 请求创建一个检查点,CRI-O 从你的低级运行时(例如 `runc`)请求一个检查点。
181+
看到这个请求,`runc` 调用 `criu` 工具来执行实际的检查点操作。
188182

189183
检查点操作完成后,检查点应该位于
190184
`/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
204198
manually create certain directories Kubernetes would create before starting the
205199
container.
206200
-->
207-
使用检查点 tar 归档文件,可以在 Kubernetes 之外的 CRI-O 沙箱实例中恢复容器。为了在恢复过程中获得更好的用户体验,我建议你使用 CRI-O GitHub 的 **main** 分支中最新版本的 CRI-O。
201+
使用检查点 tar 归档文件,可以在 Kubernetes 之外的 CRI-O 沙箱实例中恢复容器。
202+
为了在恢复过程中获得更好的用户体验,建议你使用 CRI-O GitHub 的 **main** 分支中最新版本的 CRI-O。
208203
如果你使用的是 CRI-O v1.25,你需要在启动容器之前手动创建 Kubernetes 会创建的某些目录。
209-
210204
<!--
211205
The first step to restore a container outside of Kubernetes is to create a pod sandbox
212206
using *crictl*:
@@ -347,7 +341,8 @@ spec:
347341
nodeName: <destination-node>
348342
```
349343
-->
350-
要恢复此检查点镜像(container-image-registry.example/user/checkpoint-image:latest),该镜像需要在 Pod 的规范中列出。下面是一个清单示例:
344+
要恢复此检查点镜像(container-image-registry.example/user/checkpoint-image:latest),
345+
该镜像需要在 Pod 的规约中列出。下面是一个清单示例:
351346

352347
```yaml
353348
apiVersion: v1
@@ -371,7 +366,8 @@ instead of the usual steps to create and start a container,
371366
CRI-O fetches the checkpoint data and restores the container from that
372367
specified checkpoint.
373368
-->
374-
Kubernetes 将新的 Pod 调度到一个节点上。该节点上的 kubelet 指示容器运行时(本例中为 CRI-O)基于指定为 `registry/user/checkpoint-image:latest` 的镜像创建并启动容器。
369+
Kubernetes 将新的 Pod 调度到一个节点上。该节点上的 kubelet 指示容器运行时(本例中为 CRI-O)
370+
基于指定为 `registry/user/checkpoint-image:latest` 的镜像创建并启动容器。
375371
CRI-O 检测到 `registry/user/checkpoint-image:latest` 是对检查点数据的引用,而不是容器镜像。
376372
然后,与创建和启动容器的通常步骤不同,CRI-O 获取检查点数据,并从指定的检查点恢复容器。
377373

@@ -380,7 +376,8 @@ The application in that Pod would continue running as if the checkpoint had not
380376
within the container, the application looks and behaves like any other container that had been
381377
started normally and not restored from a checkpoint.
382378
-->
383-
该 Pod 中的应用程序将继续运行,就像检查点未被获取一样;在该容器中,应用程序的外观和行为,与正常启动且未从检查点恢复的任何其他容器相似。
379+
该 Pod 中的应用程序将继续运行,就像检查点未被获取一样;在该容器中,
380+
应用程序的外观和行为,与正常启动且未从检查点恢复的任何其他容器相似。
384381

385382
<!--
386383
With these steps, it is possible to replace a Pod running on one node

content/zh-cn/blog/_posts/2023-03-10-forensic-container-analysis/index.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,19 @@ For a container named *counter* in a pod named *counters* in a namespace named
110110

111111
在分析检查点之前的最后一步是告诉 Kubernetes 创建检查点。如上一篇文章所述,这需要访问 **kubelet** 唯一的“检查点” API 端点。
112112

113-
对于名为 **default** 的命名空间中名为 **counters** 的 pod 中的名为 **counter** 的容器, **kubelet** API 端点可在以下位置访问:
113+
对于 **default** 命名空间中 **counters** Pod 中名为 **counter** 的容器,
114+
可通过以下方式访问 **kubelet** API 端点:
114115

116+
<!--
115117
```shell
116118
# run this on the node where that Pod is executing
117119
curl -X POST "https://localhost:10250/checkpoint/default/counters/counter"
118120
```
121+
-->
122+
```shell
123+
# 在运行 Pod 的节点上运行这条命令
124+
curl -X POST "https://localhost:10250/checkpoint/default/counters/counter"
125+
```
119126

120127
<!--
121128
For completeness the following `curl` command-line options are necessary to
@@ -174,7 +181,8 @@ SIZE`). This is mainly the size of the memory pages included in the checkpoint,
174181
but there is also information about the size of all changed files in the
175182
container (`ROOT FS DIFF SIZE`).
176183
-->
177-
这展示了有关该检查点归档中的检查点的一些信息。我们可以看到容器的名称、有关容器运行时和容器引擎的信息。它还列出了检查点的大小(`CHKPT SIZE`)。
184+
这展示了有关该检查点归档中的检查点的一些信息。我们可以看到容器的名称、有关容器运行时和容器引擎的信息。
185+
它还列出了检查点的大小(`CHKPT SIZE`)。
178186
这主要是检查点中包含的内存页的大小,同时也有有关容器中所有更改文件的大小的信息(`ROOT FS DIFF SIZE`)。
179187

180188
<!--
@@ -265,7 +273,8 @@ was created just as expected.
265273
With the help of `rootfs-diff.tar` it is possible to inspect all files that
266274
were created or changed compared to the base image of the container.
267275
-->
268-
与该容器所基于的容器镜像(`quay.io/adrianreber/counter:blog`)相比,它包含容器提供的服务的所有访问信息以及预期创建的 `logfile` 可以检查 `test-file` 文件。
276+
与该容器所基于的容器镜像(`quay.io/adrianreber/counter:blog`)相比,
277+
它包含容器提供的服务的所有访问信息以及预期创建的 `logfile` 可以检查 `test-file` 文件。
269278

270279
在 `rootfs-diff.tar` 的帮助下,可以根据容器的基本镜像检查所有创建或修改的文件。
271280

@@ -326,7 +335,8 @@ is more data to be analyzed in `checkpoint/pstree.img`.
326335

327336
Let's compare the so far collected information to the still running container:
328337
-->
329-
这意味着容器内的三个进程是 `bash`、`counter.py`(Python 解释器)和 `tee`。 `checkpoint/pstree.img` 中有更多数据可供分析,以获取有关进程起源的详细信息。
338+
这意味着容器内的三个进程是 `bash`、`counter.py`(Python 解释器)和 `tee`。
339+
`checkpoint/pstree.img` 中有更多数据可供分析,以获取有关进程起源的详细信息。
330340

331341
让我们将目前为止收集到的信息与仍在运行的容器进行比较。
332342

@@ -360,7 +370,8 @@ processes.
360370
One last example of what `crit` can tell us about the container is the information
361371
about the UTS namespace:
362372
-->
363-
在此输出中,我们首先获取容器中第一个进程的 PID。在运行容器的系统上,它会查找其 PID 和子进程。你应该看到三个进程,第一个进程是 `bash`,容器 PID 命名空间中的 PID 为 1。
373+
在此输出中,我们首先获取容器中第一个进程的 PID。在运行容器的系统上,它会查找其 PID 和子进程。
374+
你应该看到三个进程,第一个进程是 `bash`,容器 PID 命名空间中的 PID 为 1。
364375
然后查看 `/proc/<PID>/comm`,可以找到与检查点镜像完全相同的值。
365376

366377
需要记住的重点是,检查点包含容器的 PID 命名空间内的视图。因为这些信息对于恢复进程非常重要。
@@ -426,7 +437,8 @@ important to remember that anyone that can access the checkpoint
426437
archive has access to all information that was stored in the memory of the
427438
container's processes.
428439
-->
429-
确实有我的数据。通过这种方式,我可以轻松查看容器中进程的所有内存页面的内容,但需要注意的是可以访问检查点存档的任何人都可以访问存储在容器进程内存中的所有信息。
440+
确实有我的数据。通过这种方式,我可以轻松查看容器中进程的所有内存页面的内容,
441+
但需要注意的是可以访问检查点存档的任何人都可以访问存储在容器进程内存中的所有信息。
430442

431443
<!--
432444
#### Using gdb for further analysis
@@ -514,10 +526,13 @@ are just the starting point. Depending on your requirements it is possible to
514526
look at certain things in much more detail, but this article should give you an
515527
introduction how to start the analysis of your checkpoint.
516528
-->
517-
借助容器检查点,可以在不停止容器且在容器不知情的情况下,为正在运行的容器创建检查点。 在 Kubernetes 中对容器创建一个检查点的结果是检查点存档文件;
518-
使用不同的工具,如 `checkpointctl``tar``crit``gdb`,可以分析检查点。即使使用像 `grep` 这样的简单工具,也可以在检查点存档中找到信息。
529+
借助容器检查点,可以在不停止容器且在容器不知情的情况下,为正在运行的容器创建检查点。
530+
在 Kubernetes 中对容器创建一个检查点的结果是检查点存档文件;
531+
使用不同的工具,如 `checkpointctl``tar``crit``gdb`,可以分析检查点。
532+
即使使用像 `grep` 这样的简单工具,也可以在检查点存档中找到信息。
519533

520-
我在本文中展示的如何分析检查点的不同示例,这只是一个起点。 根据你的需求,可以更详细地查看某些内容,本文向你介绍了如何开始进行检查点分析。
534+
我在本文中展示的如何分析检查点的不同示例,这只是一个起点。
535+
根据你的需求,可以更详细地查看某些内容,本文向你介绍了如何开始进行检查点分析。
521536

522537
<!--
523538
## How do I get involved?

0 commit comments

Comments
 (0)