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
👑 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

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for kdbg-0.5.0.tar.gz
Algorithm Hash digest
SHA256 186430de7e2074ea514569cb1ab7f20438af229e53d3d43a546e94b5294cd86b
MD5 075811f649225fbc6743bfb8de725294
BLAKE2b-256 4ff1d28bc256e5fb4b5219920d713c1d591064c2fb9808d5791a2ec9f1680db0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for kdbg-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3887613ff59b4b533a6d8b13e6392ee058063cc8bc613b27752218d16814ab01
MD5 97644ebffc10d0695e97387639cc1ad5
BLAKE2b-256 ab2e086df25f0f10468c59eef054edcd2511fddf20125a615c8762063b81c801

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