Skip to content

Commit f2c49e3

Browse files
authored
Merge pull request kubernetes#2834 from verb/1.23-debug-profiles
KEP-1441: Propose profiles for kubectl debug
2 parents 6100c06 + cfbe9a3 commit f2c49e3

File tree

3 files changed

+139
-4
lines changed

3 files changed

+139
-4
lines changed

keps/prod-readiness/sig-cli/1441.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kep-number: 1441
2+
alpha:
3+
approver: "@johnbelamaric"
4+
beta:
5+
approver: "@johnbelamaric"

keps/sig-cli/1441-kubectl-debug/README.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
- [Creating a Debug Container by copy](#creating-a-debug-container-by-copy)
2020
- [Modify Application Image by Copy](#modify-application-image-by-copy)
2121
- [Node Troubleshooting with Privileged Containers](#node-troubleshooting-with-privileged-containers)
22+
- [Debugging Profiles](#debugging-profiles)
23+
- [Profile: general](#profile-general)
24+
- [Profile: baseline](#profile-baseline)
25+
- [Profile: restricted](#profile-restricted)
26+
- [Profile: sysadmin](#profile-sysadmin)
27+
- [Profile: netadmin](#profile-netadmin)
28+
- [Default Profile and Automation Selection](#default-profile-and-automation-selection)
29+
- [Future Improvements](#future-improvements)
2230
- [User Stories](#user-stories)
2331
- [Operations](#operations)
2432
- [Debugging](#debugging)
@@ -300,6 +308,130 @@ Examples:
300308
kubectl debug node/mynode -it --image=busybox
301309
```
302310

311+
### Debugging Profiles
312+
313+
Since launching `kubectl debug` we've received feedback that more configurability
314+
is needed for generated pods and containers.
315+
316+
* [kubernetes/kubernetes#97103](https://issues.k8s.io/97103): ability to set capability `SYS_PTRACE`
317+
* [kubernetes/kubectl#1051](https://github.com/kubernetes/kubectl/issues/1051): ability to set privileged
318+
* [kubernetes/kubectl#1070](https://github.com/kubernetes/kubectl/issues/1070): strip probes on pod copy
319+
* (various): ability to set `SYS_ADMIN` and `NET_ADMIN` capabilities
320+
321+
These requests are relevant for all debugging journeys. That is, a user may want to
322+
set `SYS_ADMIN` while debugging a node, a pod by ephemeral container, or a pod by copy.
323+
`kubectl debug` is intended to guide the user through a debugging scenario, and
324+
requiring the user to specify a series of flags on the command line is a poor experience.
325+
326+
Instead, we'll introduce "Debugging profiles" which are configurable via a single command
327+
line flag, `--profile`. A user may then use, for example, `--profile=netadmin` when
328+
debugging a node to create a pod with the `NET_ADMIN` capaibility.
329+
330+
The available profiles will be:
331+
332+
| Profile | Description |
333+
| ------------ | --------------------------------------------------------------- |
334+
| general | A reasonable set of defaults tailored for each debuging journey |
335+
| baseline | Compatible with baseline [Pod Security Standard] |
336+
| restricted | Compatible with restricted [Pod Security Standard] |
337+
| auto | Automatically choose between general, baseline, and restricted |
338+
| sysadmin | System Administrator (root) privileges |
339+
| netadmin | Network Administrator privileges. |
340+
| legacy | Backwards compatibility with 1.22 behavior |
341+
342+
Debugging profiles are intended to work seamlessly with the [Pod Security Standard]
343+
enforced by the [PodSecurity] admission controller. The baseline and restricted
344+
profiles will generate configuration compatible with the corresponding security
345+
level.
346+
347+
[Pod Security Standards]: https://kubernetes.io/docs/concepts/security/pod-security-standards/
348+
[PodSecurity]: http://kep.k8s.io/2579
349+
350+
#### Profile: general
351+
352+
| Journey | Debug Container Behavior |
353+
| ------------------- | -------------------------------------------------------------------------- |
354+
| Node | empty securityContext; uses host namespaces, mounts root partition |
355+
| Pod Copy | sets `SYS_PTRACE` in debugging container, sets shareProcessNamespace |
356+
| Ephemeral Container | sets `SYS_PTRACE` in ephemeral container |
357+
358+
This profile prioritizes the debugging experience for the general case. For pod debugging it sets
359+
`SYS_PTRACE` and uses pod-scoped namespaces. Probes and labels are stripped from Pod copies to
360+
ensure the copy isn't killed and doesn't receive traffic during debugging.
361+
362+
Node debugging uses host-scoped namespaces but doesn't otherwise request escalated privileges.
363+
364+
#### Profile: baseline
365+
366+
| Journey | Debug Container Behavior |
367+
| ------------------- | -------------------------------------------------------------------------- |
368+
| Node | empty securityContext; uses isolated namespaces |
369+
| Pod Copy | empty securityContext; sets shareProcessNamespace |
370+
| Ephemeral Container | empty securityContext |
371+
372+
This profile is identical to "general" but eliminates privileges that are disallowed under the
373+
baseline security profile, such as host namespaces, host volume, mounts and `SYS_PTRACE`.
374+
375+
Probes and labels continue to be stripped from Pod copies.
376+
377+
#### Profile: restricted
378+
379+
| Journey | Debug Container Behavior |
380+
| ------------------- | -------------------------------------------------------------------------- |
381+
| Node | empty securityContext; uses private namespaces |
382+
| Pod Copy | empty securityContext; sets shareProcessNamespace |
383+
| Ephemeral Container | empty securityContext |
384+
385+
This profile is identical to "baseline" but adds configuration that's required under the restricted
386+
security profile, such as requiring a non-root user and dropping all capabilities.
387+
388+
Probes and labels continue to be stripped from Pod copies.
389+
390+
#### Profile: sysadmin
391+
392+
| Journey | Debug Container Behavior |
393+
| ------------------- | -------------------------------------------------------------------------- |
394+
| Node | sets `SYS_ADMIN` and privileged; uses host namespaces |
395+
| Pod Copy | sets `SYS_ADMIN` on debugging container |
396+
| Ephemeral Container | sets `SYS_ADMIN` on ephemeral container |
397+
398+
This profile offers elevated privileges for system debugging.
399+
400+
Probes and labels are be stripped from Pod copies.
401+
402+
#### Profile: netadmin
403+
404+
| Journey | Debug Container Behavior |
405+
| ------------------- | -------------------------------------------------------------------------- |
406+
| Node | sets `NET_ADMIN` and privileged; uses host namespaces |
407+
| Pod Copy | sets `NET_ADMIN` on debugging container |
408+
| Ephemeral Container | sets `NET_ADMIN` on ephemeral container |
409+
410+
This profile offers elevated privileges for network debugging.
411+
412+
Probes and labels are be stripped from Pod copies.
413+
414+
#### Default Profile and Automation Selection
415+
416+
In order to provide a seamless experience and encourage use of [PodSecurity], the "auto"
417+
profile will automatically choose a profile that's compatible with the current security profile
418+
by examining the `pod-security.kubernetes.io/enforce` annotation on the namespace and
419+
selecting the most permissive of "general", "baseline", and "restricted" that the
420+
controller will allow.
421+
422+
This will become the default behavior, but in order to maintain backwards compatibility
423+
the "legacy" profile will be the default profile until the 1.25 release. When `--profile`
424+
is not specified `kubectl debug` will print a warning about the upcoming change in behavior.
425+
426+
#### Future Improvements
427+
428+
It might be possible to support user-configurable profiles, but it's not a goal of
429+
this KEP, and we have no plans to implement it.
430+
431+
The [PodSecurity] KEP mentions a couple of options for "break glass" functionality to allow
432+
bypassing security policy for debugging purposes. If a standard emerges for break glass, `kubectl
433+
debug` should be updated to support it.
434+
303435
### User Stories
304436

305437
#### Operations

keps/sig-cli/1441-kubectl-debug/kep.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ reviewers:
1414
approvers:
1515
- "@pwittrock"
1616
- "@soltysh"
17-
prr-approvers:
18-
- "@johnbelamaric"
1917
see-also:
2018
- "/keps/sig-node/20190212-ephemeral-containers.md"
2119
- "/keps/sig-release/20190316-rebase-images-to-distroless.md"
@@ -26,13 +24,13 @@ stage: beta
2624
# The most recent milestone for which work toward delivery of this KEP has been
2725
# done. This can be the current (upcoming) milestone, if it is being actively
2826
# worked on.
29-
latest-milestone: "v1.20"
27+
latest-milestone: "v1.23"
3028

3129
# The milestone at which this feature was, or is targeted to be, at each stage.
3230
milestone:
3331
alpha: "v1.18"
3432
beta: "v1.20"
35-
stable: "v1.22"
33+
stable: "v1.25"
3634

3735
# The following PRR answers are required at alpha release
3836
# List the feature gate name and the components for which it must be enabled

0 commit comments

Comments
 (0)