Cluster requirements
DebugHero adds an ephemeral container with Delve to your pod. Your cluster, your permissions, and your Go binary must allow this. Do the checks on this page before your first session.
Summary
| Requirement | Value |
|---|---|
| Kubernetes | 1.25 or later |
| Nodes | linux/amd64 |
| Permissions | list and get pods; update on pods/ephemeralcontainers; create on pods/portforward |
| Pod Security Admission | The namespace must allow the SYS_PTRACE capability: level privileged, or an exemption |
| Image pull | The nodes can pull docker.io/madhavhugar/debughero:0.0.9 |
| Go binary | Built with Go 1.22 to 1.25, with debug information (DWARF) |
Kubernetes version
Ephemeral containers are stable in Kubernetes 1.25 and later. To see the server version, run:
kubectl version
Nodes
The debug image is available only for linux/amd64. Pods on arm64 nodes cannot be debugged yet. This includes AWS Graviton nodes, and minikube or kind on Apple-silicon Macs.
To see the architecture of the node that runs your pod, run:
kubectl get node "$(kubectl get pod <pod> -n <namespace> -o jsonpath='{.spec.nodeName}')" \
-o jsonpath='{.status.nodeInfo.architecture}'
Permissions
debugd uses your kubeconfig (the --kubeconfig flag, else KUBECONFIG, else ~/.kube/config). Your user, or the group of your user, must have these permissions in the namespace of the target pod:
| Resource | Verbs | Why |
|---|---|---|
pods | get, list | Find the pod by labels, and watch the debug container. |
pods/ephemeralcontainers | update | Add the debug container to the pod. |
pods/portforward | create | Forward the Delve port to your machine. |
To check your permissions, run these commands. Each command must print yes.
kubectl auth can-i list pods -n <namespace>
kubectl auth can-i get pods -n <namespace>
kubectl auth can-i update pods --subresource=ephemeralcontainers -n <namespace>
kubectl auth can-i create pods --subresource=portforward -n <namespace>
Use the --subresource flag. kubectl reads pods/portforward as a pod with the name portforward, so that form gives a wrong result.
If a command prints no, ask your cluster admin to give you a role with these rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: debughero
namespace: <namespace>
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["pods/ephemeralcontainers"]
verbs: ["update"]
- apiGroups: [""]
resources: ["pods/portforward"]
verbs: ["create"]
pods/ephemeralcontainers gives a user control of the processes in a pod. Give this role only for the namespaces and the users that need it.
Admission policies
The debug container needs these settings, so that Delve can attach to your process:
- the
SYS_PTRACEcapability, runAsUser: 0,allowPrivilegeEscalation: true.
Admission controllers check ephemeral containers the same as other containers. They can reject the debug container.
Pod Security Admission
Namespace level (pod-security.kubernetes.io/enforce) | Result |
|---|---|
privileged | The debug container is allowed. |
| No label | The cluster default applies. It is privileged, unless the admin set another default in the API server configuration. |
baseline | Rejected. SYS_PTRACE is not in the allowed capabilities. |
restricted | Rejected. The container runs as root and adds a capability. |
To see the level of a namespace, run:
kubectl get namespace <namespace> -o jsonpath='{.metadata.labels}'
If the namespace uses baseline or restricted, a cluster admin must allow the debug container. For example, the admin can set the namespace to privileged, or add an exemption in the Pod Security Admission configuration of the API server.
Kyverno and OPA Gatekeeper
Policies that block added capabilities, root users, or privilege escalation also reject the debug container. Examples are the Kyverno disallow-capabilities policy and the Gatekeeper K8sPSPCapabilities template. Ask your cluster admin for an exception for ephemeral containers with names that start with debughero-.
Image pull
The nodes must pull the debug image docker.io/madhavhugar/debughero:0.0.9 from Docker Hub. If your cluster allows images only from approved registries, ask your admin to approve the image, or to copy it to an approved registry.
Go binary
Go version
The debug image contains Delve 1.25. Delve 1.25 supports binaries built with Go 1.22 to Go 1.25. Delve does not attach to binaries built with a newer Go version. Support for newer Go versions is in progress.
To see the Go version of your binary, run:
go version <path-to-binary>
Debug information
Delve needs the DWARF debug information in the binary.
| Build flags | Result |
|---|---|
Default go build | Works. The compiler optimizes the code, so some variables can show as "optimized away", and stepping can skip lines. |
-gcflags="all=-N -l" | Best result. No optimizations and no inlining. Use it for images that you plan to debug. |
-ldflags="-s -w" | Does not work. The debug information is removed. |
-trimpath | Delve works, but DebugHero cannot find the build directory, because the binary has no absolute paths. You must map the source paths yourself. See Map source paths. |