-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Merged
k8s-ci-robot
merged 5 commits into
kubernetes:main
from
mochizuki875:add_custom_profile
Nov 17, 2024
+72
−2
Merged
Changes from 4 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -718,3 +718,71 @@ Clean up the Pod when you're finished with it: | |
```shell | ||
kubectl delete pod myapp | ||
``` | ||
|
||
### Custom Profile {#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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This paragraph doesn't make sense. |
||
{{< /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`: | ||
|
||
```yaml | ||
env: | ||
- name: ENV_VAR_1 | ||
value: value_1 | ||
- name: ENV_VAR_2 | ||
value: value_2 | ||
securityContext: | ||
capabilities: | ||
add: | ||
- NET_ADMIN | ||
- SYS_TIME | ||
|
||
``` | ||
|
||
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 | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.