|
19 | 19 | - [Creating a Debug Container by copy](#creating-a-debug-container-by-copy)
|
20 | 20 | - [Modify Application Image by Copy](#modify-application-image-by-copy)
|
21 | 21 | - [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) |
22 | 30 | - [User Stories](#user-stories)
|
23 | 31 | - [Operations](#operations)
|
24 | 32 | - [Debugging](#debugging)
|
@@ -300,6 +308,130 @@ Examples:
|
300 | 308 | kubectl debug node/mynode -it --image=busybox
|
301 | 309 | ```
|
302 | 310 |
|
| 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 | + |
303 | 435 | ### User Stories
|
304 | 436 |
|
305 | 437 | #### Operations
|
|
0 commit comments