Skip to content

Commit bd97639

Browse files
committed
Mutate multiple images in kubectl debug
1 parent 8d490c4 commit bd97639

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

keps/sig-cli/1441-kubectl-debug/README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,35 +233,44 @@ Options:
233233
```
234234

235235
The modification `kubectl debug` makes to `Pod.Spec.Containers` depends on the
236-
value of the `--container` flag.
236+
value of the `--container` flag. Unlike with debugging with ephemeral
237+
containers, debugging by copy does not support generating a name for new
238+
containers.
237239

238240
#### Creating a Debug Container by copy
239241

240-
If a user does not specify a `--container` or specifies one that does not exist,
242+
If a user specifies a container name with `--container` that does not exist,
241243
then the user is instructing `kubectl debug` to create a new Debug Container in
242-
the Pod copy.
244+
the Pod copy. In this case `--image` is the container image to use for the new
245+
container.
243246

244247
```
245248
Examples:
246249
# Create a debug container as a copy of the original Pod and attach to it
247-
kubectl debug mypod -it --image=busybox --copy-to=my-debugger
250+
kubectl debug mypod -it -container=debug --image=busybox --copy-to=my-debugger
248251
```
249252

250253
#### Modify Application Image by Copy
251254

252-
If a user specifies a `--container`, then they are instructing `kubectl debug` to
253-
create a copy of the target pod with a new image for one of the containers.
255+
If a user specifies a container name with `--container` that exists, then the
256+
user is instructing `kubectl debug` to change the image for this one container
257+
to the image specified in `--image`.
258+
259+
If a user does not specify a `--container`, then they are instructing `kubectl
260+
debug` to change the image for one or more containers in the pod. In this case,
261+
`--image` is the image mutation language defined by `kubectl set image`.
254262

255263
```
256264
Examples:
257265
# Create a copy of mypod named my-debugger with my-container's image changed to busybox
258266
kubectl debug mypod --image=busybox --container=my-container --copy-to=my-debugger -- sleep 1d
259-
```
260267
261-
Note that the Pod API allows updates of container images in-place, so
262-
`--copy-to` is not necessary for this operation. `kubectl debug` isn't necessary
263-
to achieve this -- it can be done today with patch -- but `kubectl debug` could
264-
implement it as well for completeness.
268+
# Create a copy of mypod with the image of all container changed to busybox
269+
kubectl debug mypod --image=*=busybox --copy-to=my-debugger
270+
271+
# Create a copy of mypod with the specified image changes
272+
kubectl debug mypod --image=main=busybox,sidecar=debian --copy-to=my-debugger
273+
```
265274

266275
### Node Troubleshooting with Privileged Containers
267276

@@ -734,6 +743,8 @@ _This section must be completed when targeting beta graduation to a release._
734743
- *2020-01-09*: Updated KEP for debugging nodes and mark implementable.
735744
- *2020-01-15*: Added test plan.
736745
- *2020-09-20*: Updated to reflect actual implementation details.
746+
- *2020-09-23*: Add support for mutating multiple container images in
747+
debug-by-copy.
737748

738749
## Drawbacks
739750

0 commit comments

Comments
 (0)