Skip to main content

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
👑 Root by default Forces runAsUser: 0 on the ephemeral container (opt-out: --preserve-user)
🧪 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)
--preserve-user Inherit target's runAsUser/runAsGroup/runAsNonRoot instead of forcing root
--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

Inherit the target's user instead of forcing root:

kdbg -n my-namespace -p my-pod --preserve-user

Verbose output:

kdbg --log-level debug

📄 License

MIT — see LICENSE for details.

Author: obeone

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.6.0.tar.gz (17.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.6.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kdbg-0.6.0.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for kdbg-0.6.0.tar.gz
Algorithm Hash digest
SHA256 2775c6ecd2fdcec4205ac671a4b570265e19ce28f3cf7e4c5676ba3d3e6ce0b7
MD5 23ded7869f7b310fffa640a57340930b
BLAKE2b-256 c6f5fc9eb45287cb2a0395b706dd8d4e6ca5c88f44f4d73ce593302314cf6cf1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kdbg-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for kdbg-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63ee801c25f3bc3bd34b551764093b2c341be4dca0ba78d4ed06b871e7eb1b71
MD5 c2f4c8ae452695f1e9f182613f2ffb41
BLAKE2b-256 955f182806fcd3a2f6dc14c1afa16047424df644cfc56b9f85c55c7fd7f4b89f

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 Sentry Error logging StatusPage Status page