Back to Skills

k8s-debug

verified

Launch ephemeral debug container in running pod for interactive debugging. Use when you need to debug a pod without restarting it.

View on GitHub

Marketplace

eveld-claude

eveld/claude

Plugin

workflows

Repository

eveld/claude
3stars

skills/k8s-debug/SKILL.md

Last Verified

January 23, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/eveld/claude/blob/main/skills/k8s-debug/SKILL.md -a claude-code --skill k8s-debug

Installation paths:

Claude
.claude/skills/k8s-debug/
Powered by add-skill CLI

Instructions

# Debug Kubernetes Container

Launch an ephemeral debug container attached to a running pod for interactive debugging.

## When to Use

- Pod is failing but you need to inspect it live
- Need debugging tools (curl, netstat, tcpdump) not available in production container
- Want to debug without modifying production container image
- Investigating network, process, or filesystem issues in running pod

## Pre-flight Checks

### Authentication and Context
```bash
# Check kubectl context
kubectl config current-context || {
  echo "No kubectl context. Run: kubectl config use-context <context>"
  exit 1
}

# Show current context
echo "K8s Context: $(kubectl config current-context)"
```

## Workflow

### 1. Launch Debug Container

**Basic debug container**:
```bash
# Attach ephemeral debug container to running pod
kubectl debug -it <pod-name> \
  --image=nicolaka/netshoot \
  --namespace=<namespace>
```

**With specific container target** (for multi-container pods):
```bash
# Target specific container in pod
kubectl debug -it <pod-name> \
  --image=nicolaka/netshoot \
  --target=<container-name> \
  --namespace=<namespace>
```

**With custom image**:
```bash
# Use custom debug image
kubectl debug -it <pod-name> \
  --image=ubuntu:latest \
  --namespace=<namespace>
```

### 2. Common Debug Commands Inside Container

Once inside the debug container, use these commands:

**Network debugging**:
```bash
# Test HTTP endpoints
curl http://localhost:8080/health
curl -v http://database-service:5432

# Check listening ports
netstat -tulpn

# Capture network traffic
tcpdump -i any port 8080

# DNS resolution
nslookup database-service
dig +short database-service.default.svc.cluster.local
```

**Process inspection**:
```bash
# List processes
ps aux

# Monitor processes
top

# Check process details
ps aux | grep api-gateway
```

**File system inspection**:
```bash
# Check application directory
ls -la /app

# View config files
cat /app/config.yaml

# Check environment variables
env | grep

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
3509 chars