Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add description about custom profile #48154

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions content/en/docs/tasks/debug/debug-application/debug-running-pod.md
Original file line number Diff line number Diff line change
Expand Up @@ -718,3 +718,59 @@ Clean up the Pod when you're finished with it:
```shell
kubectl delete pod myapp
```

### Custom Profile {#custom-profile}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Custom Profile {#custom-profile}
## Custom profiles for ephemeral containers {#custom-profile}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as Debugging Profiles above, custom profile can be applied not only to an ephemeral containers, but also to a copied Pods or a debugging pods to debug nodes.
Although the following case uses an ephemeral container as an example, I think the title should remain more general, as it is now.
(While other examples can be provided, it would be redundant)

Furthermore, I think custom profile is an extension of debugging profile.
So it would be better for the Custom Profile section under Debugging Profiles to be at level ### instead of ##, or to add a new comprehensive section that consolidates the Debug Profile and Custom Profile.


{{< feature-state for_k8s_version="v1.31" state="beta" >}}

You can define a partial container spec as a custom profile in either YAML or JSON format.
The custom profile can be applied 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 ephemeral container or debugging container spec.
It does not support the modification of the Pod spec.
Modifications for `command`, `image`, `lifecycle`, `name` and `volumeDevices` fields
via a custom profile are not allowed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph doesn't make sense.
If modifications to a Pod spec is not supported, why are we talking about the specific fields then?

{{< /note >}}

Create a Pod named myapp as an example:

```shell
kubectl run myapp --image=busybox:1.28 --restart=Never -- sleep 1d
```

Create a custom profile in YAML or JSON format.
Here, create a YAML format file named `custom-profile.yaml`:

{{% code_sample file="debug/custom-profile.yaml" %}}
tengqm marked this conversation as resolved.
Show resolved Hide resolved

Run this command to debug the Pod using an ephemeral container with the custom profile:

```shell
kubectl debug -it myapp --image=busybox:1.28 --target=myapp --profile=general --custom=custom-profile.yaml
```

You can check that the ephemeral container has been added to the target Pod with the custom profile applied:

```shell
kubectl get pod myapp -o jsonpath='{.spec.ephemeralContainers[0].env}'
```

```
[{"name":"ENV_VAR_1","value":"value_1"},{"name":"ENV_VAR_2","value":"value_2"}]
```

```shell
kubectl get pod myapp -o jsonpath='{.spec.ephemeralContainers[0].securityContext}'
```

```
{"capabilities":{"add":["NET_ADMIN","SYS_TIME"]}}
```

Clean up the Pod when you're finished with it:

```shell
kubectl delete pod myapp
```
10 changes: 10 additions & 0 deletions content/en/examples/debug/custom-profile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
env:
- name: ENV_VAR_1
value: value_1
- name: ENV_VAR_2
value: value_2
securityContext:
capabilities:
add:
- NET_ADMIN
- SYS_TIME