Skip to content

FR: New kubectl command kubectl debug #45922

Closed
@verb

Description

Is this a BUG REPORT or FEATURE REQUEST? (choose one): FEATURE REQUEST

SIG Node is working on new functionality (feature: kubernetes/enhancements#277 , proposal: #35584) to execute a "Debug Container" in the context of a running pod for the purposes of troubleshooting. This issue is to discuss changes needed to kubectl to surface this feature.

We're aiming for an alpha release in 1.7 that includes basic functionality. As written, the proposal in #35584 calls for a new command, kubectl debug, that resembles kubectl exec. An example run is:

% kubectl debug -it --image alpine $POD -c $DEBUG_CONTAINER_NAME -- sh
/ # ps x
PID   USER     TIME   COMMAND
    1 root       0:00 /pause
   13 root       0:00 /app
   26 root       0:00 sh
   32 root       0:00 ps x
/ #

Ideally we could have reasonable defaults so that the minimum command would be something like:

% kubectl debug -it
Defaulting container name to debug.
/ # 

One departure from kubectl exec is that kubectl debug supports reattaching to a running Debug Container with a command like kubectl debug --reattach $POD $CONTAINER_NAME

Options for the command would resemble:

Execute a Debug Container in a Pod.

Options:
  -c, --container='': Name of container to create. If omitted, the default "debug" will be used.
  -i, --stdin=false: Pass stdin to the container
  -m, --image='': Container Image to use when creating debug container. If omitted, the cluster default is used.
  -t, --tty=false: Stdin is a TTY

Usage:
  kubectl debug POD [-m IMAGE ] [-c CONTAINER] -- COMMAND [args...] [options]

Since this is an alpha feature it might be nice to be able to hide it in kubectl unless alpha features are enabled. It will return an error on clusters with alpha features disabled (the default).

/cc @pwittrock

Metadata

Assignees

Labels

area/kubectlkind/featureCategorizes issue or PR as related to a new feature.priority/important-longtermImportant over the long term, but may not be staffed and/or may need multiple releases to complete.sig/cliCategorizes an issue or PR as relevant to SIG CLI.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions