Skip to content

Commit b3f42b9

Browse files
committed
[zh] Sync debug-application/debug-running-pod.md
1 parent 27e0c56 commit b3f42b9

File tree

1 file changed

+110
-8
lines changed

1 file changed

+110
-8
lines changed

content/zh-cn/docs/tasks/debug/debug-application/debug-running-pod.md

Lines changed: 110 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ root@myapp-debug:/#
699699
works, see [Share Process Namespace between Containers in a Pod](
700700
/docs/tasks/configure-pod-container/share-process-namespace/).
701701
-->
702-
* 如果你没有使用 `--container` 指定新的容器名`kubectl debug` 会自动生成的。
702+
* 如果你没有使用 `--container` 标志指定新的容器名`kubectl debug` 会自动生成的。
703703
* 默认情况下,`-i` 标志使 `kubectl debug` 附加到新容器上。
704704
你可以通过指定 `--attach=false` 来防止这种情况。
705705
如果你的会话断开连接,你可以使用 `kubectl attach` 重新连接。
@@ -896,22 +896,30 @@ kubectl delete pod node-debugger-mynode-pdx84
896896
```
897897

898898
<!--
899-
## Debugging Profiles {#debugging-profiles}
899+
## Debugging a Pod or Node while applying a profile {#debugging-profiles}
900900
901901
When using `kubectl debug` to debug a node via a debugging Pod, a Pod via an ephemeral container,
902-
or a copied Pod, you can apply a debugging profile to them using the `--profile` flag.
902+
or a copied Pod, you can apply a profile to them.
903903
By applying a profile, specific properties such as [securityContext](/docs/tasks/configure-pod-container/security-context/)
904904
are set, allowing for adaptation to various scenarios.
905-
906-
The available profiles are as follows:
905+
There are two types of profiles, static profile and custom profile.
907906
-->
908-
## 调试配置 {#debugging-profiles}
907+
## 指定应用配置来调试 Pod 或节点 {#debugging-profiles}
909908

910909
使用 `kubectl debug` 通过调试 Pod 来调试节点、通过临时容器来调试 Pod 或者调试复制的 Pod 时,
911-
你可以使用 `--profile` 标志为其应用调试配置(Debugging Profile)。通过应用配置,可以设置特定的属性(如
910+
你可以为其应用配置。通过应用配置,可以设置特定的属性(如
912911
[securityContext](/zh-cn/docs/tasks/configure-pod-container/security-context/)),
913-
以适应各种场景。
912+
以适应各种场景。有两种配置:静态配置和自定义配置。
913+
914+
<!--
915+
### Applying a Static Profile {#static-profile}
914916
917+
A static profile is a set of predefined properties, and you can apply them using the `--profile` flag.
918+
The available profiles are as follows:
919+
-->
920+
### 应用静态配置 {#static-profile}
921+
922+
静态配置是预定义的属性集,你可以使用 `--profile` 标志来应用这些属性。
915923
可用的配置如下:
916924

917925
<!--
@@ -1015,3 +1023,97 @@ Clean up the Pod when you're finished with it:
10151023
```shell
10161024
kubectl delete pod myapp
10171025
```
1026+
1027+
<!--
1028+
### Applying Custom Profile {#custom-profile}
1029+
-->
1030+
### 应用自定义配置 {#custom-profile}
1031+
1032+
{{< feature-state for_k8s_version="v1.31" state="beta" >}}
1033+
1034+
<!--
1035+
You can define a partial container spec for debugging as a custom profile in either YAML or JSON format,
1036+
and apply it using the `--custom` flag.
1037+
-->
1038+
你可以以 YAML 或 JSON 格式定义部分容器规约作为自定义配置,
1039+
并使用 `--custom` 标志来应用自定义配置。
1040+
1041+
{{< note >}}
1042+
<!--
1043+
Custom profile only supports the modification of the container spec,
1044+
but modifications to `name`, `image`, `command`, `lifecycle` and `volumeDevices` fields of the container spec
1045+
are not allowed.
1046+
It does not support the modification of the Pod spec.
1047+
-->
1048+
自定义配置仅支持修改容器规约,但不允许修改容器规约中的
1049+
`name``image``command``lifecycle``volumeDevices` 字段。
1050+
自定义配置不支持修改 Pod 规约。
1051+
{{< /note >}}
1052+
1053+
<!--
1054+
Create a Pod named myapp as an example:
1055+
-->
1056+
创建一个名为 myapp 的 Pod 作为示例:
1057+
1058+
```shell
1059+
kubectl run myapp --image=busybox:1.28 --restart=Never -- sleep 1d
1060+
```
1061+
1062+
<!--
1063+
Create a custom profile in YAML or JSON format.
1064+
Here, create a YAML format file named `custom-profile.yaml`:
1065+
-->
1066+
以 YAML 或 JSON 格式创建自定义配置。
1067+
以下创建一个名为 `custom-profile.yaml` 的 YAML 格式文件:
1068+
1069+
```yaml
1070+
env:
1071+
- name: ENV_VAR_1
1072+
value: value_1
1073+
- name: ENV_VAR_2
1074+
value: value_2
1075+
securityContext:
1076+
capabilities:
1077+
add:
1078+
- NET_ADMIN
1079+
- SYS_TIME
1080+
```
1081+
1082+
<!--
1083+
Run this command to debug the Pod using an ephemeral container with the custom profile:
1084+
-->
1085+
运行以下命令,使用带自定义配置的临时容器来调试 Pod:
1086+
1087+
```shell
1088+
kubectl debug -it myapp --image=busybox:1.28 --target=myapp --profile=general --custom=custom-profile.yaml
1089+
```
1090+
1091+
<!--
1092+
You can check that the ephemeral container has been added to the target Pod with the custom profile applied:
1093+
-->
1094+
你可以检查临时容器和应用的自定义配置是否已被添加到目标 Pod:
1095+
1096+
```shell
1097+
kubectl get pod myapp -o jsonpath='{.spec.ephemeralContainers[0].env}'
1098+
```
1099+
1100+
```
1101+
[{"name":"ENV_VAR_1","value":"value_1"},{"name":"ENV_VAR_2","value":"value_2"}]
1102+
```
1103+
1104+
```shell
1105+
kubectl get pod myapp -o jsonpath='{.spec.ephemeralContainers[0].securityContext}'
1106+
```
1107+
1108+
```
1109+
{"capabilities":{"add":["NET_ADMIN","SYS_TIME"]}}
1110+
```
1111+
1112+
<!--
1113+
Clean up the Pod when you're finished with it:
1114+
-->
1115+
你在完成上述任务后,可以执行以下命令清理 Pod:
1116+
1117+
```shell
1118+
kubectl delete pod myapp
1119+
```

0 commit comments

Comments
 (0)