From 6655ec9843a2803c79ccd8a028d059a5149ff194 Mon Sep 17 00:00:00 2001 From: mochizuki875 Date: Mon, 7 Oct 2024 07:13:19 +0000 Subject: [PATCH] fix1 --- .../debug-application/debug-running-pod.md | 58 ++++++++++++++----- content/en/examples/debug/custom-profile.json | 20 ------- content/en/examples/debug/custom-profile.yaml | 10 ---- 3 files changed, 45 insertions(+), 43 deletions(-) delete mode 100644 content/en/examples/debug/custom-profile.json delete mode 100644 content/en/examples/debug/custom-profile.yaml diff --git a/content/en/docs/tasks/debug/debug-application/debug-running-pod.md b/content/en/docs/tasks/debug/debug-application/debug-running-pod.md index 198a96d5efcc7..9d20c672d0267 100644 --- a/content/en/docs/tasks/debug/debug-application/debug-running-pod.md +++ b/content/en/docs/tasks/debug/debug-application/debug-running-pod.md @@ -723,11 +723,11 @@ kubectl delete pod myapp {{< feature-state for_k8s_version="v1.31" state="beta" >}} -You can define partial container spec as a custom profile in either YAML or JSON format, and apply it using the `--custom` flag. +You can define a partial container spec as a custom profile in either YAML or JSON format, and apply it to an ephemeral container or a debugging container in a copied Pod or a debugging Pod using the `--custom` flag. {{< note >}} -- Custom profile only supports the modification of the debug container spec. It does not support the modification of the Pod spec of the debug target. -- Modifications via custom profile is not allowed for certain fields such as command, image, lifecycle, volume devices and container name. In the future, more fields can be added to the disallowed list if required. +Custom profile only supports the modification of the debugging container spec. It does not support the modification of the Pod spec of the debug target. +Modifications via a custom profile are not allowed for certain fields, including: `command`, `image`, `lifecycle`, `name`, and fields that define access to storage. {{< /note >}} @@ -737,25 +737,57 @@ First, create a Pod named myapp as an example: kubectl run myapp --image=busybox:1.28 --restart=Never -- sleep 1d ``` -Create a custom profile in a YAML file named `custom-profile.yaml`: - -{{% code_sample file="debug/custom-profile.yaml" %}} - -You can also use JSON format for the custom profile: - -{{% code_sample file="debug/custom-profile.json" %}} +Create a custom profile in a YAML file named `custom-profile.yaml`, and you can also use JSON format for the custom profile: + +{{< tabs name="custom_profiles" >}} +{{< tab name="YAML" codelang="yaml" >}} +env: +- name: ENV_VAR_1 + value: value_1 +- name: ENV_VAR_2 + value: value_2 +securityContext: + capabilities: + add: + - NET_ADMIN + - SYS_TIME + +{{< /tab >}} +{{< tab name="JSON" codelang="json" >}} +{ + "env": [ + { + "name": "ENV_VAR_1", + "value": "value_1" + }, + { + "name": "ENV_VAR_2", + "value": "value_2" + } + ], + "securityContext": { + "capabilities": { + "add": [ + "NET_ADMIN", + "SYS_TIME" + ] + } + } +} +{{< /tab >}} +{{< /tabs >}} Then, debug the Pod using an ephemeral container with the custom profile: ```shell -kubectl debug -it myapp --image=busybox:1.28 --target=myapp --custom=custom-profile.yaml +kubectl debug -it myapp --image=busybox:1.28 --target=myapp --profile=general --custom=custom-profile.yaml ``` You can check that the ephemeral container was created with the custom profile applied: ```shell -kubectl get po myapp -o jsonpath='{.spec.ephemeralContainers[0].env}' +kubectl get pod myapp -o jsonpath='{.spec.ephemeralContainers[0].env}' ``` ``` @@ -763,7 +795,7 @@ kubectl get po myapp -o jsonpath='{.spec.ephemeralContainers[0].env}' ``` ```shell -kubectl get po myapp -o jsonpath='{.spec.ephemeralContainers[0].securityContext}' +kubectl get pod myapp -o jsonpath='{.spec.ephemeralContainers[0].securityContext}' ``` ``` diff --git a/content/en/examples/debug/custom-profile.json b/content/en/examples/debug/custom-profile.json deleted file mode 100644 index 27636c1cc2808..0000000000000 --- a/content/en/examples/debug/custom-profile.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "env": [ - { - "name": "ENV_VAR_1", - "value": "value_1" - }, - { - "name": "ENV_VAR_2", - "value": "value_2" - } - ], - "securityContext": { - "capabilities": { - "add": [ - "NET_ADMIN", - "SYS_TIME" - ] - } - } -} diff --git a/content/en/examples/debug/custom-profile.yaml b/content/en/examples/debug/custom-profile.yaml deleted file mode 100644 index 7f7f23398225f..0000000000000 --- a/content/en/examples/debug/custom-profile.yaml +++ /dev/null @@ -1,10 +0,0 @@ -env: -- name: ENV_VAR_1 - value: value_1 -- name: ENV_VAR_2 - value: value_2 -securityContext: - capabilities: - add: - - NET_ADMIN - - SYS_TIME