Skip to content

Commit 8ea74b9

Browse files
committed
Add README.md
1 parent 53bbe65 commit 8ea74b9

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Debugging container for Kubernetes
2+
3+
## How to use the Image
4+
5+
If you want to debug an existing Pod, simply attach to it like this:
6+
7+
```shell
8+
kubectl debug -it <POD> --image=ghcr.io/boomer41/debug-container --image-pull-policy=Always
9+
```
10+
11+
You are then dropped into a shell - by default `zsh`.
12+
13+
## Usage
14+
15+
### Get Root
16+
17+
It is good practice to run Pods as non-root.
18+
However, debugging sometimes needs root.
19+
20+
This images comes with a privilege escalation **by design**, to facilitate easy root access.
21+
If you are not root, simply type `get-root`, and you'll be dropped into a new root shell.
22+
23+
### Dump the Pod's Network Traffic
24+
25+
Sometimes there is just the need to see exactly *what* is being handled by the Pod.
26+
This image contains an easy way to push the traffic to your local computer in order to decode it with Wireshark.
27+
28+
To dump the traffic, follow those steps:
29+
30+
1. Ensure you are root. If not, execute `get-root`.
31+
2. Execute `tcpdump-port`. By default, it listens to port `10000/tcp`.
32+
If that port is already in use, select another port by using `--port <PORT>`.
33+
3. In a second shell: Create a Port-Forward to the Pod: `kubectl port-forward pods/<POD> 10001:10000`.
34+
This opens port `10001/tcp` on your **local machine** and forwards it to the pod's port `10000/tcp`.
35+
Remember to adjust this command if you had to use a different port in step 2!
36+
4. In a third shell: Launch Wireshark.
37+
Remember to adjust the port here if you had to use a different **local** port in step 3!
38+
39+
For Linux: `nc -v 127.0.0.1 10001 | wireshark -k -i -`
40+
41+
For macOS: `nc -v 127.0.0.1 10001 | /Applications/Wireshark.app/Contents/MacOS/Wireshark -k -i -`
42+
43+
If you want to see all parameters of the program, execute `tcpdump-port --help`.
44+

0 commit comments

Comments
 (0)