Skip to content

Commit 55081d6

Browse files
kubectl-debug: add page (#18635)
Signed-off-by: Emmanuel Ferdman <[email protected]>
1 parent 837c837 commit 55081d6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

pages/common/kubectl-debug.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# kubectl debug
2+
3+
> Debug cluster resources using interactive debugging containers.
4+
> More information: <https://kubernetes.io/docs/reference/kubectl/generated/kubectl_debug>.
5+
6+
- Create an interactive debugging session in a pod and immediately attach to it:
7+
8+
`kubectl debug {{pod_name}} {{[-it|--stdin --tty]}} --image busybox`
9+
10+
- Create a debug container with a custom image and name:
11+
12+
`kubectl debug --image {{image}} {{[-c|--container]}} {{container_name}} {{pod_name}}`
13+
14+
- 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`):
15+
16+
`kubectl debug node/{{node_name}} {{[-it|--stdin --tty]}} --image busybox`
17+
18+
- Create a copy of a pod and add a debug container to it:
19+
20+
`kubectl debug {{pod_name}} {{[-it|--stdin --tty]}} --image {{image}} --copy-to {{pod_copy_name}}`
21+
22+
- Create a copy of a pod and change the command of a specific container:
23+
24+
`kubectl debug {{pod_name}} {{[-it|--stdin --tty]}} --copy-to {{pod_copy_name}} --container {{container_name}} -- {{command}}`
25+
26+
- Create a copy of a pod and change the image of a specific container:
27+
28+
`kubectl debug {{pod_name}} --copy-to {{pod_copy_name}} --set-image {{container_name}}={{image}}`
29+
30+
- Create a copy of a pod and change all container images:
31+
32+
`kubectl debug {{pod_name}} --copy-to {{pod_copy_name}} --set-image '*={{image}}'`
33+
34+
- Create an ephemeral debug container and target a specific container (useful for debugging distroless containers):
35+
36+
`kubectl debug {{pod_name}} {{[-it|--stdin --tty]}} --image {{image}} --target {{target_container_name}}`

0 commit comments

Comments
 (0)