Skip to content

Commit cfbe9a3

Browse files
committed
Incorporate feedback for kubectl debug profiles
1 parent caa43c0 commit cfbe9a3

File tree

2 files changed

+46
-39
lines changed

2 files changed

+46
-39
lines changed

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

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
- [Modify Application Image by Copy](#modify-application-image-by-copy)
2121
- [Node Troubleshooting with Privileged Containers](#node-troubleshooting-with-privileged-containers)
2222
- [Debugging Profiles](#debugging-profiles)
23-
- [Default Profile and Automation Selection](#default-profile-and-automation-selection)
24-
- [Profile: debug](#profile-debug)
23+
- [Profile: general](#profile-general)
2524
- [Profile: baseline](#profile-baseline)
2625
- [Profile: restricted](#profile-restricted)
2726
- [Profile: sysadmin](#profile-sysadmin)
2827
- [Profile: netadmin](#profile-netadmin)
28+
- [Default Profile and Automation Selection](#default-profile-and-automation-selection)
29+
- [Future Improvements](#future-improvements)
2930
- [User Stories](#user-stories)
3031
- [Operations](#operations)
3132
- [Debugging](#debugging)
@@ -312,9 +313,9 @@ Examples:
312313
Since launching `kubectl debug` we've received feedback that more configurability
313314
is needed for generated pods and containers.
314315

315-
* [kubernetes/kubernetes#97103]: ability to set capability `SYS_PTRACE`
316-
* [kubernetes/kubectl#1051]: ability to set privileged
317-
* [kubernetes/kubectl#1070]: strip probes on pod copy
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
318319
* (various): ability to set `SYS_ADMIN` and `NET_ADMIN` capabilities
319320

320321
These requests are relevant for all debugging journeys. That is, a user may want to
@@ -330,10 +331,10 @@ The available profiles will be:
330331

331332
| Profile | Description |
332333
| ------------ | --------------------------------------------------------------- |
333-
| debug | A reasonable set of defaults tailored for each debuging journey |
334+
| general | A reasonable set of defaults tailored for each debuging journey |
334335
| baseline | Compatible with baseline [Pod Security Standard] |
335336
| restricted | Compatible with restricted [Pod Security Standard] |
336-
| auto | Automatically choose between debug, baseline, and restricted |
337+
| auto | Automatically choose between general, baseline, and restricted |
337338
| sysadmin | System Administrator (root) privileges |
338339
| netadmin | Network Administrator privileges. |
339340
| legacy | Backwards compatibility with 1.22 behavior |
@@ -343,43 +344,20 @@ enforced by the [PodSecurity] admission controller. The baseline and restricted
343344
profiles will generate configuration compatible with the corresponding security
344345
level.
345346

346-
It might be possible to support user-configurable profiles, but it's not a goal of
347-
this KEP, and we have no plans to implement it.
348-
349347
[Pod Security Standards]: https://kubernetes.io/docs/concepts/security/pod-security-standards/
350348
[PodSecurity]: http://kep.k8s.io/2579
351349

352-
#### Default Profile and Automation Selection
353-
354-
The profile named "debug" will generate the best configuration for a particular
355-
debugging journey, for example including `SYS_PTRACE` for ephemeral containers
356-
so that a debugging container may signal and attach to other processes.
357-
358-
The profile named "auto" will choose between "debug", "baseline", and "restricted"
359-
by looking `pod-security.kubernetes.io/enforce` annotation on the namespace and
360-
choosing the most permission of "debug", "baseline", and "restricted" that will
361-
be allowed by default. In this way it will choose a default that's always
362-
compatible with the current security policy.
363-
364-
When not `--profile` is not specified it will default to "legacy" to be backwards
365-
compatible with the current behavior and print a warning that the behavior will
366-
change starting with release 1.25. Starting with 1.25 the default will be "auto".
367-
368-
Even with automatic selection it's still desirable to be able to specify "debug",
369-
"baseline", and "restricted" explicitly. In the future there will be an optional
370-
"break glass" mechanism to bypass the current security policy for debugging.
371-
372-
#### Profile: debug
350+
#### Profile: general
373351

374352
| Journey | Debug Container Behavior |
375353
| ------------------- | -------------------------------------------------------------------------- |
376354
| Node | empty securityContext; uses host namespaces, mounts root partition |
377355
| Pod Copy | sets `SYS_PTRACE` in debugging container, sets shareProcessNamespace |
378356
| Ephemeral Container | sets `SYS_PTRACE` in ephemeral container |
379357

380-
This profile is intended to be a useful default. For pod debugging it sets `SYS_PTRACE` and uses
381-
pod-scoped namespaces. Probes and labels are stripped from Pod copies to ensure the copy isn't
382-
killed and doesn't receive traffic during debugging.
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.
383361

384362
Node debugging uses host-scoped namespaces but doesn't otherwise request escalated privileges.
385363

@@ -391,8 +369,10 @@ Node debugging uses host-scoped namespaces but doesn't otherwise request escalat
391369
| Pod Copy | empty securityContext; sets shareProcessNamespace |
392370
| Ephemeral Container | empty securityContext |
393371

394-
This profile eliminates the privileges from "debug" that are disallowed under the baseline security
395-
profile, such as host namespaces, host volume mounts and `SYS_PTRACE`.
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.
396376

397377
#### Profile: restricted
398378

@@ -402,8 +382,10 @@ profile, such as host namespaces, host volume mounts and `SYS_PTRACE`.
402382
| Pod Copy | empty securityContext; sets shareProcessNamespace |
403383
| Ephemeral Container | empty securityContext |
404384

405-
This profile adds configuration to "baseline" that's required under the restricted security profile,
406-
such as requiring a non-root user and dropping all capabilities.
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.
407389

408390
#### Profile: sysadmin
409391

@@ -415,6 +397,8 @@ such as requiring a non-root user and dropping all capabilities.
415397

416398
This profile offers elevated privileges for system debugging.
417399

400+
Probes and labels are be stripped from Pod copies.
401+
418402
#### Profile: netadmin
419403

420404
| Journey | Debug Container Behavior |
@@ -425,6 +409,29 @@ This profile offers elevated privileges for system debugging.
425409

426410
This profile offers elevated privileges for network debugging.
427411

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+
428435
### User Stories
429436

430437
#### Operations

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ latest-milestone: "v1.23"
3030
milestone:
3131
alpha: "v1.18"
3232
beta: "v1.20"
33-
stable: "v1.24"
33+
stable: "v1.25"
3434

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

0 commit comments

Comments
 (0)