Skip to content

Commit 0c8a63f

Browse files
committed
add description about debugging profile
1 parent 71c870d commit 0c8a63f

File tree

2 files changed

+82
-2
lines changed

2 files changed

+82
-2
lines changed

content/en/docs/tasks/debug/debug-application/debug-running-pod.md

+80-1
Original file line numberDiff line numberDiff line change
@@ -632,10 +632,89 @@ When creating a debugging session on a node, keep in mind that:
632632
* The container runs in the host IPC, Network, and PID namespaces, although
633633
the pod isn't privileged, so reading some process information may fail,
634634
and `chroot /host` may fail.
635-
* If you need a privileged pod, create it manually.
635+
* If you need a privileged pod, create it manually or use the `--profile=sysadmin` flag.
636636

637637
Don't forget to clean up the debugging Pod when you're finished with it:
638638

639639
```shell
640640
kubectl delete pod node-debugger-mynode-pdx84
641641
```
642+
643+
## Debugging Profiles {#debugging-profiles}
644+
645+
When using `kubectl debug` to debug a node via a debugging Pod, a Pod via an ephemeral container,
646+
or a copied Pod, you can apply a debugging profile to them using the `--profile` flag.
647+
By applying a profile, specific properties such as [securityContext](/docs/tasks/configure-pod-container/security-context/)
648+
are set, allowing for adaptation to various scenarios.
649+
650+
651+
The available profiles are as follows:
652+
653+
| Profile | Description |
654+
| ------------ | --------------------------------------------------------------- |
655+
| legacy | A set of properties backwards compatibility with 1.22 behavior |
656+
| general | A reasonable set of generic properties for each debugging journey |
657+
| baseline | A set of properties compatible with [PodSecurityStandard baseline policy](/docs/concepts/security/pod-security-standards/#baseline) |
658+
| restricted | A set of properties compatible with [PodSecurityStandard restricted policy](/docs/concepts/security/pod-security-standards/#restricted) |
659+
| netadmin | A set of properties including Network Administrator privileges |
660+
| sysadmin | A set of properties including System Administrator (root) privileges |
661+
662+
663+
{{< note >}}
664+
If you don't specify `--profile`, the `legacy` profile is used by default, but it is planned to be deprecated in the near future.
665+
So it is recommended to use other profiles such as `general`.
666+
{{< /note >}}
667+
668+
669+
Assume that you create a Pod and debug it.
670+
First, create a Pod named `myapp` as an example:
671+
672+
```shell
673+
kubectl run myapp --image=busybox:1.28 --restart=Never -- sleep 1d
674+
```
675+
676+
Then, debug the Pod using an ephemeral container.
677+
If the ephemeral container needs to have privilege, you can use the `sysadmin` profile:
678+
679+
```shell
680+
kubectl debug -it myapp --image=busybox:1.28 --target=myapp --profile=sysadmin
681+
```
682+
683+
```
684+
Targeting container "myapp". If you don't see processes from this container it may be because the container runtime doesn't support this feature.
685+
Defaulting debug container name to debugger-6kg4x.
686+
If you don't see a command prompt, try pressing enter.
687+
/ #
688+
```
689+
690+
Check the capabilities of the ephemeral container process by running the following command inside the container:
691+
692+
```shell
693+
/ # grep Cap /proc/$$/status
694+
```
695+
696+
```
697+
...
698+
CapPrm: 000001ffffffffff
699+
CapEff: 000001ffffffffff
700+
...
701+
```
702+
703+
This means the container process is granted full capabilities as a privileged container by applying `sysadmin` profile.
704+
See more details about [capabilities](/docs/tasks/configure-pod-container/security-context/#set-capabilities-for-a-container).
705+
706+
You can also check that the ephemeral container was created as a privileged container:
707+
708+
```shell
709+
kubectl get pod myapp -o jsonpath='{.spec.ephemeralContainers[0].securityContext}'
710+
```
711+
712+
```
713+
{"privileged":true}
714+
```
715+
716+
Clean up the Pod when you're finished with it:
717+
718+
```shell
719+
kubectl delete pod myapp
720+
```

content/en/docs/tasks/debug/debug-cluster/kubectl-node-debug.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ When creating a debugging session on a Node, keep in mind that:
7575
* Although the container runs in the host IPC, Network, and PID namespaces,
7676
the pod isn't privileged. This means that reading some process information might fail
7777
because access to that information is restricted to superusers. For example, `chroot /host` will fail.
78-
If you need a privileged pod, create it manually.
78+
If you need a privileged pod, create it manually or use the `--profile=sysadmin` flag.
79+
* By applying [Debugging Profiles](/docs/tasks/debug/debug-application/debug-running-pod/#debugging-profiles), you can set specific properties such as [securityContext](/docs/tasks/configure-pod-container/security-context/) to a debugging Pod.
7980

8081
## {{% heading "cleanup" %}}
8182

0 commit comments

Comments
 (0)