kdebug 0.2.0__py3-none-any.whl

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.
@@ -0,0 +1,318 @@
1
+ Metadata-Version: 2.4
2
+ Name: kdebug
3
+ Version: 0.2.0
4
+ Summary: Universal Kubernetes Debug Container Utility
5
+ Project-URL: Homepage, https://github.com/jessegoodier/kdebug
6
+ Project-URL: Repository, https://github.com/jessegoodier/kdebug
7
+ Author: Jesse Goodier
8
+ License-Expression: MIT
9
+ Keywords: cli,debug,kubectl,kubernetes
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: MacOS
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Programming Language :: Python :: 3
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/markdown
18
+
19
+ # kdebug - Universal Kubernetes Debug and File Copy Container Utility
20
+
21
+ Simple utility for launching ephemeral debug containers in Kubernetes pods with interactive shell access, backup capabilities, and a colorful TUI for pod selection.
22
+
23
+ ## Features
24
+
25
+
26
+ - 🐚 **Interactive Shell Access** - Launch bash/zsh sessions in debug containers directly to the directory of your choice
27
+ - 💾 **Backup Capabilities** - Copy files/directories from pods with optional compression
28
+ - 🔍 **Multiple Selection Modes** - Direct pod, controller-based, or interactive tui
29
+ - đŸŽ¯ **Smart Container Selection** - Auto-select containers or choose specific targets
30
+ - 🔐 **Root Access Support** - Run debug containers as root when needed
31
+ - đŸ“Ļ **Controller Support** - Works with Deployments, StatefulSets, and DaemonSets
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ brew install jessegoodier/kdebug/kdebug
37
+ ```
38
+
39
+ Or
40
+
41
+ ```bash
42
+ # Clone the repository
43
+ git clone https://github.com/jessegoodier/kdebug.git
44
+ cd kdebug
45
+ ```
46
+
47
+ Then make it is executable and add to something in your PATH
48
+
49
+ ```
50
+ chmod +x bin/kdebug
51
+ ln -s $(pwd)/bin/kdebug ~/.local/bin/kdebug
52
+ ```
53
+
54
+ ## Shell Completion
55
+
56
+ kdebug supports tab completion for bash and zsh with dynamic lookups for namespaces, pods, and controller names.
57
+
58
+ ### Bash
59
+
60
+ ```bash
61
+ # Add to ~/.bashrc
62
+ source <(kdebug --completions bash)
63
+
64
+ # Or source the file directly
65
+ source /path/to/kdebug/completions/kdebug.bash
66
+ ```
67
+
68
+ ### Zsh
69
+
70
+ ```bash
71
+ # Option 1: Source directly (add to ~/.zshrc)
72
+ source <(kdebug --completions zsh)
73
+
74
+ # Option 2: Install to fpath (recommended)
75
+ mkdir -p ~/.zsh/completions
76
+ kdebug --completions zsh > ~/.zsh/completions/_kdebug
77
+ # Add to ~/.zshrc before compinit:
78
+ fpath=(~/.zsh/completions $fpath)
79
+ autoload -Uz compinit && compinit
80
+ ```
81
+
82
+ ### Completion Features
83
+
84
+ - `kdebug --<TAB>` - Complete all options
85
+ - `kdebug -n <TAB>` - Complete namespace names from cluster
86
+ - `kdebug --pod <TAB>` - Complete pod names (respects -n flag)
87
+ - `kdebug --controller <TAB>` - Complete controller types
88
+ - `kdebug --controller sts --controller-name <TAB>` - Complete controller names
89
+ - `kdebug --context <TAB>` - Complete context names from kubeconfig
90
+ - `kdebug --kubeconfig <TAB>` - Complete file paths
91
+
92
+ ## Usage
93
+
94
+ ### Global Options
95
+
96
+ kdebug supports kubectl-compatible `--context` and `--kubeconfig` flags to target different clusters:
97
+
98
+ ```bash
99
+ # Use a specific context
100
+ kdebug --context minikube -n default --pod my-pod
101
+
102
+ # Use a different kubeconfig file
103
+ kdebug --kubeconfig .kubeconfig -n openclaw
104
+
105
+ # Combine both options
106
+ kdebug --kubeconfig /path/to/config --context staging -n myapp --pod api-0
107
+ ```
108
+
109
+ These options are passed to all kubectl commands, including those used for tab completion.
110
+
111
+ ### Interactive Mode (TUI)
112
+
113
+ When no pod or controller is specified, kdebug launches an interactive menu system:
114
+
115
+ # Interactive mode - select from all resources in current namespace
116
+ ```bash
117
+ kdebug
118
+ ```
119
+
120
+ # Interactive mode with specific namespace
121
+
122
+ ```bash
123
+ kdebug -n openclaw
124
+ ```
125
+
126
+ **TUI Features:**
127
+ - âŦ†ī¸âŦ‡ī¸ Use arrow keys to navigate
128
+ - 1ī¸âƒŖ-9ī¸âƒŖ Press numbers for quick selection
129
+ - â†Šī¸ Press Enter to confirm
130
+ - ❌ Press 'q' to quit
131
+
132
+ The TUI displays all pods in the namespace with:
133
+ - Color-coded status indicators (Green=Running, Yellow=Pending, etc.)
134
+ - Pod names highlighted for easy identification
135
+ - Real-time status information
136
+
137
+ ### Direct Pod Selection
138
+
139
+ ```bash
140
+ # Interactive session with direct pod
141
+ kdebug -n kubecost --pod aggregator-0 --container aggregator
142
+
143
+ # Auto-select first container if not specified
144
+ kdebug -n kubecost --pod aggregator-0
145
+
146
+ # Custom shell command
147
+ kdebug -n kubecost --pod aggregator-0 --cmd sh
148
+ ```
149
+
150
+ ### Controller-Based Selection
151
+
152
+ ```bash
153
+ # Using StatefulSet (sts)
154
+ kdebug -n kubecost --controller sts --controller-name aggregator --container aggregator
155
+
156
+ # Using Deployment
157
+ kdebug -n myapp --controller deployment --controller-name frontend --cmd bash
158
+
159
+ # Using DaemonSet
160
+ kdebug -n logging --controller ds --controller-name fluentd
161
+ ```
162
+
163
+ **Supported Controller Types:**
164
+ - `deployment` or `deploy` - Kubernetes Deployments
165
+ - `statefulset` or `sts` - StatefulSets
166
+ - `daemonset` or `ds` - DaemonSets
167
+
168
+ ### Advanced Features
169
+
170
+ #### Change Directory on Start
171
+
172
+ ```bash
173
+ # Start shell in specific directory
174
+ kdebug -n kubecost --pod aggregator-0 --cd-into /var/configs
175
+ ```
176
+
177
+ #### Backup Mode
178
+
179
+ ```bash
180
+ # Backup directory (uncompressed)
181
+ kdebug -n kubecost --pod aggregator-0 --backup /var/configs
182
+
183
+ # Backup with compression
184
+ kdebug -n kubecost --pod aggregator-0 --backup /var/configs --compress
185
+
186
+ # Backups are saved to: ./backups/<namespace>/<timestamp>_<pod-name>
187
+ ```
188
+
189
+ #### Run as Root
190
+
191
+ ```bash
192
+ # Launch debug container as root user
193
+ kdebug -n myapp --pod frontend-abc123 --as-root
194
+ ```
195
+
196
+ #### Debug Mode
197
+
198
+ ```bash
199
+ # Show all kubectl commands being executed
200
+ kdebug -n myapp --pod frontend-abc123 --debug
201
+ ```
202
+
203
+ ## Examples
204
+
205
+ ### Example 1: Interactive Pod Selection
206
+
207
+ ```bash
208
+ $ kdebug -n production
209
+
210
+ Starting interactive pod selection...
211
+
212
+ ══════════════════════════════════════════════════════════════════════
213
+ Select Pod in namespace: production
214
+ ══════════════════════════════════════════════════════════════════════
215
+
216
+ â–ļ 1. frontend-abc123 (Running)
217
+ 2. frontend-def456 (Running)
218
+ 3. backend-ghi789 (Running)
219
+ 4. database-0 (Running)
220
+ 5. worker-jkl012 (Pending)
221
+
222
+ ──────────────────────────────────────────────────────────────────────
223
+ Use ↑/↓ arrows or numbers to select, Enter to confirm, q to quit
224
+ ──────────────────────────────────────────────────────────────────────
225
+ ```
226
+
227
+ ### Example 2: Quick Debug Session
228
+
229
+ ```bash
230
+ # Launch debug container and get bash shell
231
+ kdebug -n kubecost --controller sts --controller-name aggregator --container aggregator
232
+
233
+ # Output:
234
+ # ══════════════════════════════════════════════════════════════════════
235
+ # Starting interactive session in pod aggregator-0
236
+ # Container: debugger-xyz
237
+ # Command: bash
238
+ # ══════════════════════════════════════════════════════════════════════
239
+ ```
240
+
241
+ ### Example 3: Backup Configuration Files
242
+
243
+ ```bash
244
+ # Backup with compression
245
+ kdebug -n production --pod api-server-0 --backup /etc/app/config --compress
246
+
247
+ # Output:
248
+ # ══════════════════════════════════════════════════════════════════════
249
+ # Creating backup from pod api-server-0
250
+ # Path: /etc/app/config
251
+ # Mode: Compressed (tar.gz)
252
+ # ══════════════════════════════════════════════════════════════════════
253
+ # ✓ Path exists: /etc/app/config
254
+ # ✓ Backup archive created
255
+ # ✓ Backup saved to: ./backups/production/2024-02-04_10-30-45_api-server-0.tar.gz
256
+ ```
257
+
258
+ ## Color Scheme
259
+
260
+ kdebug uses a kubecolor-inspired color scheme:
261
+
262
+ - đŸ”ĩ **Blue** - Borders and separators
263
+ - đŸŸĸ **Green** - Success messages and running status
264
+ - 🟡 **Yellow** - Warnings and pending status
265
+ - 🔴 **Red** - Errors and failed status
266
+ - đŸŸŖ **Magenta** - Namespaces
267
+ - 🔷 **Cyan** - Pod and container names
268
+ - âšĒ **White/Gray** - General text and metadata
269
+
270
+ ## Requirements
271
+
272
+ - Python 3.6+
273
+ - kubectl configured with cluster access
274
+ - Kubernetes cluster with ephemeral containers support (v1.23+)
275
+
276
+ ## How It Works
277
+
278
+ 1. **Resource Discovery** - Queries Kubernetes API for controllers/pods
279
+ 2. **Debug Container Launch** - Creates ephemeral container with debug image
280
+ 3. **Process Sharing** - Enables `--share-processes` for full pod access
281
+ 4. **Interactive Session** - Attaches to container with TTY
282
+ 5. **Cleanup** - Terminates debug container after session ends
283
+
284
+ ## Troubleshooting
285
+
286
+ ### "Operation not supported on socket" Error
287
+
288
+ The interactive TUI requires a real terminal (TTY). Ensure you're running kdebug in:
289
+ - A standard terminal (not piped or redirected)
290
+ - Not through automation tools that don't provide TTY
291
+ - With proper terminal emulation support
292
+
293
+ ### "Pod Security Policy" Warnings
294
+
295
+ If you see warnings about `runAsNonRoot`, the pod has security restrictions. Try:
296
+ - Running without `--as-root` flag
297
+ - Checking pod security policies
298
+ - Using a different debug image
299
+
300
+ ### Container Won't Start
301
+
302
+ Check:
303
+ - Debug image is accessible from cluster
304
+ - Pod has sufficient resources
305
+ - Network policies allow image pull
306
+ - Use `--debug` flag to see kubectl commands
307
+
308
+ ## License
309
+
310
+ MIT
311
+
312
+ ## Contributing
313
+
314
+ Contributions welcome! Please open issues or pull requests.
315
+
316
+ ---
317
+
318
+ Made with â¤ī¸ and Bob
@@ -0,0 +1,6 @@
1
+ kdebug/__init__.py,sha256=OOhp8y3zVAw6RzVcSq4wtyeAzPneUnVw-b2OIXtjgTc,182
2
+ kdebug/cli.py,sha256=OBeBwem1AzinYYn-90XgFOpOemB1R09XxlS48o9r84M,49147
3
+ kdebug-0.2.0.dist-info/METADATA,sha256=oO5wbmX-pVXsIQQumlWaIkBkpNV2LFAXbBMtfVMBixY,9924
4
+ kdebug-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
5
+ kdebug-0.2.0.dist-info/entry_points.txt,sha256=SSMhCgTQLJEK7RwCvlEiskLgk3_zXzTssTu6d-1_sJo,43
6
+ kdebug-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ kdebug = kdebug.cli:main