11---
2- title : Pod Troubleshooting
2+ title : kubectl debug
33authors :
44 - " @verb"
55owning-sig : sig-cli
@@ -80,20 +80,22 @@ Check these off as they are completed for the Release Team to track. These check
8080
8181## Summary
8282
83- This proposal adds a command to ` kubectl ` allowing troubleshooting a running pod
84- with tools provided in an arbitrary container image by making use of [ ephemeral
85- containers ] . ` kubectl debug ` parallels the existing, ` kubectl exec ` . Whereas
86- ` kubectl exec ` runs a _ process _ in a _ container _ , ` kubectl debug ` runs a
87- _ container _ in a _ pod _ .
83+ This proposal adds a command to ` kubectl ` to improve the user experience of
84+ troubleshooting. Current ` kubectl ` commands such as ` exec ` and ` port-forward `
85+ allow this sort of troubleshooting at the container and network layer. `kubectl
86+ debug` extends these capabilities to include Kubernetes abstractions such as
87+ Pod, Node and [ Ephemeral Containers ] .
8888
89- For example, the following command would attach to a newly created container in
90- a pod:
89+ Workflows supported by the initial release of ` kubectl debug ` are:
9190
92- ```
93- kubectl debug -c debug-shell --image=debian target-pod -- bash
94- ```
91+ 1 . Create an Ephemeral Container in a running Pod to attach debugging tools
92+ to a distroless container image. * (pod debugging)*
93+ 2 . Restart a pod with a modified ` PodSpec ` , to allow in-place troubleshooting
94+ using different container images or permissions. * (pod debugging)*
95+ 3 . Start and attach to a privileged container in the host namespace.
96+ * (node debugging)*
9597
96- [ ephemeral containers ] : https://git.k8s.io/enhancements/keps/sig-node/20190212-ephemeral-containers.md
98+ [ Ephemeral Containers ] : https://git.k8s.io/enhancements/keps/sig-node/20190212-ephemeral-containers.md
9799
98100## Motivation
99101
@@ -148,24 +150,26 @@ Make available to users of Kubernetes a troubleshooting facility that:
1481503 . does not require administrative access to the node.
149151
150152New ` kubectl ` concepts increase cognitive burden for all users of Kubernetes.
151- This KEP seeks to minimize this burden by mirroring the existing ` kubectl exec `
152- workflow .
153+ This KEP seeks to minimize this burden by mirroring the existing ` kubectl `
154+ workflows where possible .
153155
154156### Non-Goals
155157
156158Ephemeral containers are supported on Windows, but it's not the recommended
157- debugging facility. Debugging relies on process namespace sharing, which isn't
158- implemented by the Windows container runtime, and Windows containers cannot be
159- built ` FROM scratch ` so debugging tools are already available in the container.
160- While not excluding Windows containers, this KEP will focus on the Linux use
161- case.
159+ debugging facility. The other troubleshooting workflows described here are
160+ equally as useful to Windows containers. We will not attempt to create
161+ separate debugging facilities for Windows containers.
162162
163163[ distroless container image ] : https://github.com/GoogleCloudPlatform/distroless
164164[ distroless for k8s system images ] : https://git.k8s.io/enhancements/keps/sig-release/20190316-rebase-images-to-distroless.md
165165[ scratch debugger ] : https://github.com/kubernetes-retired/contrib/tree/master/scratch-debugger
166166
167167## Proposal
168168
169+ TODO: Add other troubleshooting workflows.
170+
171+ ### Pod Troubleshooting with Ephemeral Containers
172+
169173We will add a new command ` kubectl debug ` that will:
170174
1711751 . Construct a ` v1.Container ` for the debug container based on command line
@@ -178,7 +182,7 @@ We will add a new command `kubectl debug` that will:
1781824 . [ optional] Watch pod for updates to the debug container's ` ContainerStatus `
179183 and automatically attach once the container is running.
180184
181- ### Debug Container Naming
185+ #### Debug Container Naming
182186
183187Currently, there is no support for deleting or recreating ephemeral containers.
184188In cases where the user does not specify a name, ` kubectl ` will generate a
@@ -195,7 +199,7 @@ that support container namespace targeting.
195199
196200[ Process Namespace Sharing ] : https://kubernetes.io/docs/tasks/configure-pod-container/share-process-namespace
197201
198- ### Interactive Troubleshooting and Automatic Attaching
202+ #### Interactive Troubleshooting and Automatic Attaching
199203
200204Since the primary use case for ` kubectl debug ` is interactive troubleshooting,
201205` kubectl debug ` will automatically attach to the console of the newly created
@@ -204,7 +208,7 @@ ephemeral container and will default to creating containers with `Stdin` and
204208
205209These may be disabled via command line flags.
206210
207- ### Proposed ` kubectl debug ` arguments
211+ #### Proposed ` kubectl debug ` arguments
208212
209213```
210214% kubectl help debug
0 commit comments