⎈ k8s knowledge compiler

kubectl debug [page]deterministic

Create debugging sessions for troubleshooting workloads and nodes

reference

##

Debug cluster resources using interactive debugging containers.

'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by default if no resource is specified.

The action taken by 'debug' varies depending on what resource is specified. Supported actions include:

* Workload: Create a copy of an existing pod with certain attributes changed, for example changing the image tag to a new version. * Workload: Add an ephemeral container to an already running pod, for example to add debugging utilities without restarting the pod. * Node: Create a new pod that runs in the node's host namespaces and can access the node's filesystem.

Note: When a non-root user is configured for the entire target Pod, some capabilities granted by debug profile may not work.

``` kubectl debug (POD | TYPE[[.VERSION].GROUP]/NAME) [ -- COMMAND [args...] ] ```

##

``` # Create an interactive debugging session in pod mypod and immediately attach to it. kubectl debug mypod -it --image=busybox # Create an interactive debugging session for the pod in the file pod.yaml and immediately attach to it. # (requires the EphemeralContainers feature to be enabled in the cluster) kubectl debug -f pod.yaml -it --image=busybox # Create a debug container named debugger using a custom automated debugging image. kubectl debug --image=myproj/debug-tools -c debugger mypod # Create a copy of mypod adding a debug container and attach to it kubectl debug mypod -it --image=busybox --copy-to=my-debugger # Create a copy of mypod changing the command of mycontainer kubectl debug mypod -it --copy-to=my-debugger --container=mycontainer -- sh # Create a copy of mypod changing all container images to busybox kubectl debug mypod --copy-to=my-debugger --set-image=*=busybox # Create a copy of mypod adding a debug container and changing container images kubectl debug mypod -it --copy-to=my-debugger --image=debian --set-image=app=app:debug,sidecar=sidecar:debug # Create an interactive debugging session on a node and immediately attach to it. # The container will run in the host namespaces and the host's filesystem will be mounted at /host kubectl debug node/mynode -it --image=busybox ```

##

<table style="width: 100%; table-layout: fixed;"> <colgroup> <col span="1" style="width: 10px;" /> <col span="1" /> </colgroup> <tbody>

<tr> <td colspan="2">--arguments-only</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>If specified, everything after -- will be passed to the new container as Args instead of Command.</p></td> </tr>

<tr> <td colspan="2">--attach</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>If true, wait for the container to start running, and then attach as if 'kubectl attach ...' were called. Default false, unless '-i/--stdin' is set, in which case the default is true.</p></td> </tr>

<tr> <td colspan="2">-c, --container string</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>Container name to use for debug container.</p></td> </tr>

<tr> <td colspan="2">--copy-to string</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>Create a copy of the target Pod with this name.</p></td> </tr>

<tr> <td colspan="2">--custom string</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>Path to a JSON or YAML file containing a partial container spec to customize built-in debug profiles.</p></td> </tr>

<tr> <td colspan="2">--env stringToString&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default: []</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>Environment variables to set in the container.</p></td> </tr>

<tr> <td colspan="2">-f, --filename strings</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>identifying the resource to debug</p> …(trimmed)

Sources

reference/kubectl/generated/kubectl_debug/_index.md · dockubectl debug

Related (5)

part_of {{% heading "synopsis" %}}describes conf=1
part_of {{% heading "examples" %}}describes conf=1
part_of {{% heading "options" %}}describes conf=1
part_of {{% heading "parentoptions" %}}describes conf=1
part_of {{% heading "seealso" %}}describes conf=1

← all Docs