Skip to content

Commit 4be1ce9

Browse files
authored
docs: use debug ephemeral containers (#769)
1 parent ad727ff commit 4be1ce9

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,27 @@ py-spy needs `SYS_PTRACE` to be able to read process memory. Kubernetes drops th
234234
```
235235
Permission Denied: Try running again with elevated permissions by going 'sudo env "PATH=$PATH" !!'
236236
```
237-
The recommended way to deal with this is to edit the spec and add that capability. For a deployment, this is done by adding this to `Deployment.spec.template.spec.containers`
237+
The recommended way to deal with this is to edit the spec and add that capability. For a Deployment, this is done by adding this to `Deployment.spec.template.spec.containers`
238238
```
239239
securityContext:
240240
capabilities:
241241
add:
242242
- SYS_PTRACE
243243
```
244244
More details on this here: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-capabilities-for-a-container
245-
Note that this will remove the existing pods and create those again.
245+
Note that if you modify the Deployment resource, this will remove the existing Pods and create those again.
246+
247+
You can also create an **ephemeral container** to attach to a running Pod, targeting a specific **container** where your application is running.
248+
Make sure to use a `profile` that grants the `SYS_PTRACE` permission, for example:
249+
250+
```sh
251+
kubectl debug --profile=general \
252+
-n your-namespace \
253+
--target=app-container-name \
254+
pod-name \
255+
--image=python:3.12-slim \
256+
-it -- bash
257+
```
246258

247259
### How do I install py-spy on Alpine Linux?
248260

0 commit comments

Comments
 (0)