Skip to main content

Interactive CLI to launch privileged debug containers against running Kubernetes pods.

Project description

kdbg

Python Kubernetes License PyPI

Interactive CLI to launch privileged debug containers against running Kubernetes pods. Wraps kubectl debug with fzf-powered selection and automatic Pod Security Admission management.

flowchart TB
    A[kdbg] --> B{Interactive selection}
    B --> C[Context]
    B --> D[Namespace]
    B --> E[Pod]
    B --> F[Container]
    C & D & E & F --> G[Apply privileged PSA label]
    G --> H[kubectl debug -it]
    H --> I[Debug session]
    I --> J[Cleanup PSA label]

🚀 Features

Feature Description
🔍 Interactive selection fzf-powered picker for context, namespace, pod, and container
🐳 Custom debug image --image to use any debug image (default: obeoneorg/netshoot)
🔒 PSA management Auto-applies privileged label, cleans up on exit
🧪 Dry-run mode --dry-run prints the generated kubectl command
🎨 Colored logging Adjustable verbosity with --log-level
🐚 Shell completion Bash, Zsh, and Fish completion scripts
⚙️ Security profiles --profile or KDBG_PROFILE env var

📋 Prerequisites

  • kubectl — Kubernetes CLI, configured with cluster access
  • fzf — command-line fuzzy finder

📦 Installation

From PyPI (recommended)

uv tool install kdbg

or with pipx:

pipx install kdbg

From GitHub

uv tool install \
  'kdbg @ git+https://github.com/obeone/scripts.git#subdirectory=kdbg'

From a local clone

git clone https://github.com/obeone/scripts.git
uv tool install ./scripts/kdbg

Shell completion

Add the appropriate line to your shell configuration file:

Bash (~/.bashrc):

eval "$(kdbg --completion bash)"

Zsh (~/.zshrc):

eval "$(kdbg --completion zsh)"

Fish (~/.config/fish/config.fish):

kdbg --completion fish | source

🛠️ Usage

Quick start

Run without arguments for full interactive mode:

kdbg

Direct targeting

kdbg -C my-cluster -n my-namespace -p my-pod -c app-container

Common options

Option Description
-C, --context Kubernetes context
-n, --namespace Target namespace
-p, --pod Target pod
-c, --container Target container
-i, --image Debug image (default: obeoneorg/netshoot)
--profile Security profile (default: sysadmin)
--dry-run Print command without executing
-l, --log-level debug, info, warn, error

Examples

Custom debug image:

kdbg --image busybox:latest

Dry-run to inspect the command:

kdbg -n my-namespace -p my-pod --dry-run

Run a command in the debug container:

kdbg -n my-namespace -p my-pod -- tcpdump -i eth0

Verbose output:

kdbg --log-level debug

📄 License

MIT — see LICENSE for details.

Author: obeone

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kdbg-0.4.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kdbg-0.4.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file kdbg-0.4.0.tar.gz.

File metadata

  • Download URL: kdbg-0.4.0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for kdbg-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b7094e82235ed78180b6905735eefac705e3827f1c6a9f1d814f1261f31108e1
MD5 bb462a7cbe8010244a194ba1f82b997d
BLAKE2b-256 343726568f7712487be6615b271463b06495005860f21fa0b15db6b04b050e50

See more details on using hashes here.

File details

Details for the file kdbg-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: kdbg-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for kdbg-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 65b7f7e2f6020d16399c2949124c2d2d9547c62a247952a726927cee238a5f18
MD5 da7ce1716250e5e48d49d3842d8b103f
BLAKE2b-256 ff1e35cef89a5e7e0bb3dc75596f6617959d6f4e2ea20714b39b6a17adb4ae81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page