kdebug 0.4.1__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kdebug-0.4.1 → kdebug-0.5.0}/PKG-INFO +172 -97
- {kdebug-0.4.1 → kdebug-0.5.0}/README.md +171 -96
- {kdebug-0.4.1 → kdebug-0.5.0}/pyproject.toml +17 -1
- {kdebug-0.4.1 → kdebug-0.5.0}/src/kdebug/cli.py +351 -82
- {kdebug-0.4.1 → kdebug-0.5.0}/src/kdebug/completions/_kdebug +43 -7
- {kdebug-0.4.1 → kdebug-0.5.0}/src/kdebug/completions/kdebug.bash +41 -7
- {kdebug-0.4.1 → kdebug-0.5.0}/.gitignore +0 -0
- {kdebug-0.4.1 → kdebug-0.5.0}/src/kdebug/__init__.py +0 -0
- {kdebug-0.4.1 → kdebug-0.5.0}/src/kdebug/completions/__init__.py +0 -0
- {kdebug-0.4.1 → kdebug-0.5.0}/src/kdebug/completions/kdebug.fish +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kdebug
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Universal Kubernetes Debug Container Utility
|
|
5
5
|
Project-URL: Homepage, https://github.com/jessegoodier/kdebug
|
|
6
6
|
Project-URL: Repository, https://github.com/jessegoodier/kdebug
|
|
@@ -22,14 +22,17 @@ Simple utility for launching ephemeral debug containers in Kubernetes pods with
|
|
|
22
22
|
|
|
23
23
|
Similar to [kpf](https://github.com/jessegoodier/kpf), this is a python wrapper around `kubectl debug` and `kubectl cp`.
|
|
24
24
|
|
|
25
|
+
>Notice: the default debug container image is <https://github.com/jessegoodier/toolbox/tree/main/common> and may not be ideal for all users. This is configurable both with an arg and a global config file
|
|
26
|
+
|
|
25
27
|
## Features
|
|
26
28
|
|
|
27
|
-
- 🐚 **Interactive Shell Access** - Launch bash/
|
|
28
|
-
- 💾 **Backup Capabilities** - Copy files/directories from pods with optional compression
|
|
29
|
-
- 🔍 **Multiple Selection Modes** - Direct pod, controller-based, or interactive
|
|
29
|
+
- 🐚 **Interactive Shell Access** - Launch bash/sh sessions in debug containers directly to the directory of your choice
|
|
30
|
+
- 💾 **Backup Capabilities** - Copy files/directories from pods with optional compression and configurable local paths
|
|
31
|
+
- 🔍 **Multiple Selection Modes** - Direct pod, controller-based, or interactive TUI
|
|
30
32
|
- 🎯 **Smart Container Selection** - Auto-select containers or choose specific targets
|
|
31
33
|
- 🔐 **Root Access Support** - Run debug containers as root when needed
|
|
32
34
|
- 📦 **Controller Support** - Works with Deployments, StatefulSets, and DaemonSets
|
|
35
|
+
- ⚙️ **Config File** - Set defaults for debug image, shell command, and backup paths
|
|
33
36
|
|
|
34
37
|
<details open>
|
|
35
38
|
<summary>Demo of the debug TUI</summary>
|
|
@@ -49,64 +52,19 @@ Similar to [kpf](https://github.com/jessegoodier/kpf), this is a python wrapper
|
|
|
49
52
|
brew install jessegoodier/kdebug/kdebug
|
|
50
53
|
```
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
# Clone the repository
|
|
56
|
-
git clone https://github.com/jessegoodier/kdebug.git
|
|
57
|
-
cd kdebug
|
|
58
|
-
```
|
|
55
|
+
## Usage
|
|
59
56
|
|
|
60
|
-
|
|
57
|
+
kdebug uses subcommands for its two modes of operation:
|
|
61
58
|
|
|
62
59
|
```
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
## Shell Completion
|
|
68
|
-
|
|
69
|
-
kdebug supports tab completion for bash and zsh with dynamic lookups for namespaces, pods, and controller names.
|
|
70
|
-
|
|
71
|
-
### Bash
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
# Add to ~/.bashrc
|
|
75
|
-
source <(kdebug --completions bash)
|
|
76
|
-
|
|
77
|
-
# Or source the file directly
|
|
78
|
-
source /path/to/kdebug/completions/kdebug.bash
|
|
60
|
+
kdebug debug [options] # Interactive debug session (default)
|
|
61
|
+
kdebug backup [options] # Backup files from pod
|
|
62
|
+
kdebug [options] # Same as "kdebug debug" for convenience
|
|
79
63
|
```
|
|
80
64
|
|
|
81
|
-
### Zsh
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
# Option 1: Source directly (add to ~/.zshrc)
|
|
85
|
-
source <(kdebug --completions zsh)
|
|
86
|
-
|
|
87
|
-
# Option 2: Install to fpath (recommended)
|
|
88
|
-
mkdir -p ~/.zsh/completions
|
|
89
|
-
kdebug --completions zsh > ~/.zsh/completions/_kdebug
|
|
90
|
-
# Add to ~/.zshrc before compinit:
|
|
91
|
-
fpath=(~/.zsh/completions $fpath)
|
|
92
|
-
autoload -Uz compinit && compinit
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Completion Features
|
|
96
|
-
|
|
97
|
-
- `kdebug --<TAB>` - Complete all options
|
|
98
|
-
- `kdebug -n <TAB>` - Complete namespace names from cluster
|
|
99
|
-
- `kdebug --pod <TAB>` - Complete pod names (respects -n flag)
|
|
100
|
-
- `kdebug --controller <TAB>` - Complete controller types
|
|
101
|
-
- `kdebug --controller sts --controller-name <TAB>` - Complete controller names
|
|
102
|
-
- `kdebug --context <TAB>` - Complete context names from kubeconfig
|
|
103
|
-
- `kdebug --kubeconfig <TAB>` - Complete file paths
|
|
104
|
-
|
|
105
|
-
## Usage
|
|
106
|
-
|
|
107
65
|
### Global Options
|
|
108
66
|
|
|
109
|
-
|
|
67
|
+
These shared options work with both subcommands:
|
|
110
68
|
|
|
111
69
|
```bash
|
|
112
70
|
# Use a specific context
|
|
@@ -119,8 +77,6 @@ kdebug --kubeconfig .kubeconfig -n openclaw
|
|
|
119
77
|
kdebug --kubeconfig /path/to/config --context staging -n myapp --pod api-0
|
|
120
78
|
```
|
|
121
79
|
|
|
122
|
-
These options are passed to all kubectl commands, including those used for tab completion.
|
|
123
|
-
|
|
124
80
|
### Interactive Mode (TUI)
|
|
125
81
|
|
|
126
82
|
When no pod or controller is specified, kdebug launches an interactive menu system:
|
|
@@ -133,41 +89,42 @@ kdebug
|
|
|
133
89
|
kdebug -n openclaw
|
|
134
90
|
```
|
|
135
91
|
|
|
136
|
-
|
|
137
|
-
- ⬆️⬇️ Use arrow keys to navigate
|
|
138
|
-
- 1️⃣-9️⃣ Press numbers for quick selection
|
|
139
|
-
- ↩️ Press Enter to confirm
|
|
140
|
-
- ❌ Press 'q' to quit
|
|
141
|
-
|
|
142
|
-
The TUI displays all pods in the namespace with:
|
|
143
|
-
- Color-coded status indicators (Green=Running, Yellow=Pending, etc.)
|
|
144
|
-
- Pod names highlighted for easy identification
|
|
145
|
-
- Real-time status information
|
|
92
|
+
### Debug Subcommand
|
|
146
93
|
|
|
147
|
-
|
|
94
|
+
The `debug` subcommand (or naked `kdebug`) launches an interactive shell session in an ephemeral debug container.
|
|
148
95
|
|
|
149
96
|
```bash
|
|
150
|
-
# Interactive session with direct pod
|
|
97
|
+
# Interactive session with direct pod (bare usage = debug)
|
|
151
98
|
kdebug -n kubecost --pod aggregator-0 --container aggregator
|
|
152
99
|
|
|
100
|
+
# Explicit debug subcommand with custom shell
|
|
101
|
+
kdebug debug -n kubecost --pod aggregator-0 --cmd sh
|
|
102
|
+
|
|
153
103
|
# Auto-select first container if not specified
|
|
154
|
-
kdebug -n kubecost --pod aggregator-0
|
|
104
|
+
kdebug debug -n kubecost --pod aggregator-0
|
|
155
105
|
|
|
156
|
-
#
|
|
157
|
-
kdebug -n kubecost --pod aggregator-0 --
|
|
106
|
+
# Change to a directory on start
|
|
107
|
+
kdebug debug -n kubecost --pod aggregator-0 --cd-into /var/configs
|
|
158
108
|
```
|
|
159
109
|
|
|
110
|
+
**Debug-specific options:**
|
|
111
|
+
|
|
112
|
+
| Option | Description |
|
|
113
|
+
|---|---|
|
|
114
|
+
| `--cmd CMD` | Command to run in debug container (default: `bash`) |
|
|
115
|
+
| `--cd-into DIR` | Change to directory on start (via `/proc/1/root`) |
|
|
116
|
+
|
|
160
117
|
### Controller-Based Selection
|
|
161
118
|
|
|
162
119
|
```bash
|
|
163
120
|
# Using StatefulSet (sts)
|
|
164
|
-
kdebug
|
|
121
|
+
kdebug --controller sts/aggregator --container aggregator
|
|
165
122
|
|
|
166
123
|
# Using Deployment
|
|
167
|
-
kdebug -n myapp --controller
|
|
124
|
+
kdebug -n myapp --controller deploy/frontend --cmd sh
|
|
168
125
|
|
|
169
126
|
# Using DaemonSet
|
|
170
|
-
kdebug -n logging --controller ds
|
|
127
|
+
kdebug -n logging --controller ds/fluentd
|
|
171
128
|
```
|
|
172
129
|
|
|
173
130
|
**Supported Controller Types:**
|
|
@@ -175,41 +132,155 @@ kdebug -n logging --controller ds --controller-name fluentd
|
|
|
175
132
|
- `statefulset` or `sts` - StatefulSets
|
|
176
133
|
- `daemonset` or `ds` - DaemonSets
|
|
177
134
|
|
|
178
|
-
###
|
|
135
|
+
### Backup Subcommand
|
|
179
136
|
|
|
180
|
-
|
|
137
|
+
The `backup` subcommand copies files or directories from a pod to your local machine.
|
|
181
138
|
|
|
182
139
|
```bash
|
|
183
|
-
#
|
|
184
|
-
kdebug -n kubecost --pod aggregator-0 --
|
|
140
|
+
# Backup a directory (uncompressed)
|
|
141
|
+
kdebug backup -n kubecost --pod aggregator-0 --container-path /var/configs
|
|
142
|
+
|
|
143
|
+
# Backup with compression
|
|
144
|
+
kdebug backup -n kubecost --pod aggregator-0 --container-path /var/configs --compress
|
|
145
|
+
|
|
146
|
+
# Backup with a custom local path using template variables
|
|
147
|
+
kdebug backup --pod web-0 --container-path /var/data \
|
|
148
|
+
--local-path ./my-backups/{namespace}/{pod}
|
|
149
|
+
|
|
150
|
+
# Backup using controller selection
|
|
151
|
+
kdebug backup --controller deploy/kubecost-local-store \
|
|
152
|
+
--container-path /var/configs/localBucket_v002
|
|
185
153
|
```
|
|
186
154
|
|
|
187
|
-
|
|
155
|
+
**Backup-specific options:**
|
|
188
156
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
157
|
+
| Option | Description |
|
|
158
|
+
|---|---|
|
|
159
|
+
| `--container-path PATH` | **(required)** Path inside the container to back up |
|
|
160
|
+
| `--local-path TEMPLATE` | Local destination (default: `./backups/{namespace}/{date}_{pod}`) |
|
|
161
|
+
| `--compress` | Compress backup as tar.gz |
|
|
162
|
+
| `--tar-exclude PATH` | Exclude a path or pattern from the archive (repeatable) |
|
|
192
163
|
|
|
193
|
-
|
|
194
|
-
kdebug -n kubecost --pod aggregator-0 --backup /var/configs --compress
|
|
164
|
+
**Using `--tar-exclude`:**
|
|
195
165
|
|
|
196
|
-
|
|
166
|
+
Excludes are matched against paths inside the archive and can be repeated. Provide a name or relative pattern — **do not include the full container path prefix**:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Exclude a single subdirectory by name
|
|
170
|
+
kdebug backup -n kubecost --pod aggregator-0 --container-path /var/configs \
|
|
171
|
+
--compress --tar-exclude waterfowl
|
|
172
|
+
|
|
173
|
+
# Exclude multiple paths
|
|
174
|
+
kdebug backup -n kubecost --pod aggregator-0 --container-path /var/configs \
|
|
175
|
+
--compress --tar-exclude waterfowl --tar-exclude tmp --tar-exclude '*.log'
|
|
197
176
|
```
|
|
198
177
|
|
|
199
|
-
|
|
178
|
+
**Template variables for `--local-path`:**
|
|
179
|
+
|
|
180
|
+
| Variable | Value |
|
|
181
|
+
|---|---|
|
|
182
|
+
| `{namespace}` | Kubernetes namespace |
|
|
183
|
+
| `{pod}` | Pod name |
|
|
184
|
+
| `{date}` | Timestamp (`YYYY-MM-DD_HH-MM-SS`) |
|
|
185
|
+
| `{container}` | Target container name |
|
|
186
|
+
|
|
187
|
+
### Run as Root
|
|
200
188
|
|
|
201
189
|
```bash
|
|
202
190
|
# Launch debug container as root user
|
|
203
191
|
kdebug -n myapp --pod frontend-abc123 --as-root
|
|
204
192
|
```
|
|
205
193
|
|
|
206
|
-
|
|
194
|
+
### Verbose Mode
|
|
207
195
|
|
|
208
196
|
```bash
|
|
209
197
|
# Show all kubectl commands being executed
|
|
210
|
-
kdebug -n myapp --pod frontend-abc123 --
|
|
198
|
+
kdebug -n myapp --pod frontend-abc123 --verbose
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Config File
|
|
202
|
+
|
|
203
|
+
kdebug supports a JSON config file at `~/.config/kdebug/kdebug.json` (respects `XDG_CONFIG_HOME`). CLI flags always take priority over config values.
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"debugImage": "busybox:latest",
|
|
208
|
+
"cmd": "sh",
|
|
209
|
+
"cdInto": "/app",
|
|
210
|
+
"backupContainerPath": "/var/data",
|
|
211
|
+
"backupLocalPath": "./backups/{namespace}/{date}_{pod}"
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
| Key | Description | Default |
|
|
216
|
+
|---|---|---|
|
|
217
|
+
| `debugImage` | Debug container image | `ghcr.io/jessegoodier/toolbox-common:latest` |
|
|
218
|
+
| `cmd` | Shell command for debug sessions | `bash` |
|
|
219
|
+
| `cdInto` | Directory to cd into on start | *(none)* |
|
|
220
|
+
| `backupContainerPath` | Default container path for backups | *(none)* |
|
|
221
|
+
| `backupLocalPath` | Default local path template for backups | `./backups/{namespace}/{date}_{pod}` |
|
|
222
|
+
|
|
223
|
+
String values support `${ENV_VAR}` expansion:
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"debugImage": "${MY_DEBUG_IMAGE}",
|
|
228
|
+
"backupLocalPath": "${HOME}/kdebug-backups/{namespace}/{date}_{pod}"
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Example: Using busybox as debug image
|
|
233
|
+
|
|
234
|
+
If you don't need the full toolbox image, busybox is a lightweight alternative:
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"debugImage": "busybox:latest",
|
|
239
|
+
"cmd": "sh"
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Since busybox doesn't include bash, set `cmd` to `sh`. With this config, simply run `kdebug --pod my-pod` and it will use busybox with sh automatically.
|
|
244
|
+
|
|
245
|
+
## Shell Completion
|
|
246
|
+
|
|
247
|
+
kdebug supports tab completion for bash and zsh with dynamic lookups for namespaces, pods, controller names, and subcommands.
|
|
248
|
+
|
|
249
|
+
### Bash
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# Add to ~/.bashrc
|
|
253
|
+
source <(kdebug --completions bash)
|
|
254
|
+
|
|
255
|
+
# Or source the file directly
|
|
256
|
+
source /path/to/kdebug/completions/kdebug.bash
|
|
211
257
|
```
|
|
212
258
|
|
|
259
|
+
### Zsh
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Option 1: Source directly (add to ~/.zshrc)
|
|
263
|
+
source <(kdebug --completions zsh)
|
|
264
|
+
|
|
265
|
+
# Option 2: Install to fpath (recommended)
|
|
266
|
+
mkdir -p ~/.zsh/completions
|
|
267
|
+
kdebug --completions zsh > ~/.zsh/completions/_kdebug
|
|
268
|
+
# Add to ~/.zshrc before compinit:
|
|
269
|
+
fpath=(~/.zsh/completions $fpath)
|
|
270
|
+
autoload -Uz compinit && compinit
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Completion Features
|
|
274
|
+
|
|
275
|
+
- `kdebug <TAB>` - Complete subcommands (`debug`, `backup`)
|
|
276
|
+
- `kdebug --<TAB>` - Complete shared options
|
|
277
|
+
- `kdebug debug --<TAB>` - Complete debug-specific options
|
|
278
|
+
- `kdebug backup --<TAB>` - Complete backup-specific options
|
|
279
|
+
- `kdebug -n <TAB>` - Complete namespace names from cluster
|
|
280
|
+
- `kdebug --pod <TAB>` - Complete pod names (respects -n flag)
|
|
281
|
+
- `kdebug --controller <TAB>` - Complete controller types and names
|
|
282
|
+
- `kdebug --context <TAB>` - Complete context names from kubeconfig
|
|
283
|
+
|
|
213
284
|
## Examples
|
|
214
285
|
|
|
215
286
|
### Example 1: Interactive Pod Selection
|
|
@@ -238,7 +309,7 @@ Use ↑/↓ arrows or numbers to select, Enter to confirm, q to quit
|
|
|
238
309
|
|
|
239
310
|
```bash
|
|
240
311
|
# Launch debug container and get bash shell
|
|
241
|
-
kdebug -n kubecost --controller sts
|
|
312
|
+
kdebug -n kubecost --controller sts/aggregator --container aggregator
|
|
242
313
|
|
|
243
314
|
# Output:
|
|
244
315
|
# ══════════════════════════════════════════════════════════════════════
|
|
@@ -248,21 +319,25 @@ kdebug -n kubecost --controller sts --controller-name aggregator --container agg
|
|
|
248
319
|
# ══════════════════════════════════════════════════════════════════════
|
|
249
320
|
```
|
|
250
321
|
|
|
251
|
-
### Example 3: Backup
|
|
322
|
+
### Example 3: Backup with Custom Local Path
|
|
252
323
|
|
|
253
324
|
```bash
|
|
254
|
-
# Backup with compression
|
|
255
|
-
kdebug -n production --pod api-server-0
|
|
325
|
+
# Backup with compression to a custom path
|
|
326
|
+
kdebug backup -n production --pod api-server-0 \
|
|
327
|
+
--container-path /etc/app/config \
|
|
328
|
+
--local-path ./config-backups/{namespace}/{date}_{pod} \
|
|
329
|
+
--compress
|
|
256
330
|
|
|
257
331
|
# Output:
|
|
258
332
|
# ══════════════════════════════════════════════════════════════════════
|
|
259
333
|
# Creating backup from pod api-server-0
|
|
260
|
-
#
|
|
334
|
+
# Container path: /etc/app/config
|
|
335
|
+
# Local path: ./config-backups/production/2024-02-04_10-30-45_api-server-0.tar.gz
|
|
261
336
|
# Mode: Compressed (tar.gz)
|
|
262
337
|
# ══════════════════════════════════════════════════════════════════════
|
|
263
338
|
# ✓ Path exists: /etc/app/config
|
|
264
339
|
# ✓ Backup archive created
|
|
265
|
-
# ✓ Backup saved to: ./backups/production/2024-02-04_10-30-45_api-server-0.tar.gz
|
|
340
|
+
# ✓ Backup saved to: ./config-backups/production/2024-02-04_10-30-45_api-server-0.tar.gz
|
|
266
341
|
```
|
|
267
342
|
|
|
268
343
|
## Color Scheme
|
|
@@ -313,7 +388,7 @@ Check:
|
|
|
313
388
|
- Debug image is accessible from cluster
|
|
314
389
|
- Pod has sufficient resources
|
|
315
390
|
- Network policies allow image pull
|
|
316
|
-
- Use `--
|
|
391
|
+
- Use `--verbose` flag to see kubectl commands
|
|
317
392
|
|
|
318
393
|
## License
|
|
319
394
|
|
|
@@ -325,4 +400,4 @@ Contributions welcome! Please open issues or pull requests.
|
|
|
325
400
|
|
|
326
401
|
---
|
|
327
402
|
|
|
328
|
-
Made with ❤️ and Bob
|
|
403
|
+
Made with ❤️ and Bob
|