debugctl debug
Start a debug session for a pod
Synopsis
Start a debug session for a Go process in a Kubernetes pod.
debugd selects the first pod in the namespace that matches the labels. It adds an ephemeral container with Delve to the pod, attaches Delve to the target process, and forwards the Delve port to localhost. The pod does not restart.
The session starts in the background. Run "debugctl get sessions" to see its status and the local Delve port. Then connect your IDE to that port.
The kubeconfig is found in the same order as kubectl: the --kubeconfig flag, then the KUBECONFIG environment variable, then ~/.kube/config. KUBECONFIG can be a list of files; the files are merged. debugd uses the current context. If "kubectl get pods" works in your shell, debugctl uses the same cluster.
debugctl debug [flags]
Examples
# Debug the pod with the label app=checkout in the namespace payments
debugctl debug --namespace payments --labels app=checkout
# Debug the container "api" of the pod, and attach to the process "server"
debugctl debug -n payments -l app=checkout -c api -m server
# Also forward the application port 8080 to localhost:8080
debugctl debug -n payments -l app=checkout --port 8080
# Use the merged config of two kubeconfig files, the same as kubectl
KUBECONFIG=~/.kube/dev.yaml:~/.kube/prod.yaml debugctl debug -l app=checkout
Options
-c, --container string target container (default: the first container of the pod)
-h, --help help for debug
-k, --kubeconfig string path of the kubeconfig file (default: $KUBECONFIG, else ~/.kube/config)
-l, --labels string label selector of the target pod, for example app=checkout (required)
-m, --match-process string text to find the target process in the process list (default: PID 1)
-n, --namespace string namespace of the target pod (default "default")
-p, --port string application port to forward to the same port on localhost
See also
- debugctl - Start and manage DebugHero debug sessions