cilium-dbg exec commands missing -n kube-system namespace flag
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in pkg/cilium/cilium.go at runCiliumDbgCommandWithContext and compare its kubectl exec arguments with getCiliumPodNameWithContext. Verify the cilium-dbg tools with Cilium in kube-system and kagent-tools in another namespace. Done means exec targets kube-system and runs without the interactive TTY flags.
Written by the indexing model from the issue text.
Description
cilium-dbg exec commands missing -n kube-system namespace flag
Bug Description
The runCiliumDbgCommandWithContext function in pkg/cilium/cilium.go finds the cilium pod using -n kube-system but then runs kubectl exec without specifying the namespace. This causes all cilium-dbg based tools to fail when the kagent-tools pod runs in a different namespace.
Root Cause
In pkg/cilium/cilium.go, line 604-628:
func getCiliumPodNameWithContext(ctx context.Context, nodeName string) (string, error) {
args := []string{"get", "pods", "-n", "kube-system", "--selector=k8s-app=cilium", ...}
// ✅ correctly uses -n kube-system to find the pod
...
}
func runCiliumDbgCommandWithContext(ctx context.Context, command, nodeName string) (string, error) {
podName, err := getCiliumPodNameWithContext(ctx, nodeName)
...
args := []string{"exec", "-it", podName, "--", "cilium-dbg", command}
// ❌ missing -n kube-system
// ❌ -it flag causes issues in non-interactive/automated contexts
...
}
The pod name is resolved correctly from kube-system, but the subsequent kubectl exec defaults to the namespace of the kagent-tools pod (e.g. kagent-tools), so it fails with:
Error from server (NotFound): pods "cilium-rwzxv" not found
Reproduction
- Deploy kagent-tools in a namespace other than
kube-system(e.g.kagent-tools) - Call any cilium debug tool (e.g.
cilium_get_endpoints_list,cilium_get_endpoint_health) with a validnode_name - The tool finds the cilium pod name but
kubectl execfails because it looks in the wrong namespace
Manual verification:
# Fails (no namespace specified, defaults to kagent-tools ns):
kubectl exec cilium-rwzxv -- cilium-dbg endpoint list
# Error from server (NotFound): pods "cilium-rwzxv" not found
# Works (with namespace):
kubectl exec cilium-rwzxv -n kube-system -- cilium-dbg endpoint list
# ENDPOINT POLICY (ingress) ...
Affected Tools
All tools that go through runCiliumDbgCommandWithContext:
cilium_get_endpoints_listcilium_get_endpoint_healthcilium_get_endpoint_detailscilium_get_endpoint_logscilium_list_identitiescilium_get_identity_detailscilium_request_debugging_informationcilium_display_encryption_statecilium_get_daemon_statuscilium_show_configuration_optionscilium_list_envoy_configcilium_fqdn_cachecilium_show_dns_namescilium_list_ip_addressescilium_show_ip_cache_informationcilium_list_bpf_map_eventscilium_list_bpf_mapscilium_get_bpf_mapcilium_list_metricscilium_list_cluster_nodescilium_list_node_idscilium_list_servicescilium_get_service_informationcilium_display_policy_node_informationcilium_display_selectorscilium_list_pcap_recorderscilium_get_pcap_recorder- And all write variants
Suggested Fix
func runCiliumDbgCommandWithContext(ctx context.Context, command, nodeName string) (string, error) {
podName, err := getCiliumPodNameWithContext(ctx, nodeName)
if err != nil {
return "", err
}
args := []string{"exec", "-n", "kube-system", podName, "--", "cilium-dbg", command}
kubeconfigPath := utils.GetKubeconfig()
return commands.NewCommandBuilder("kubectl").
WithArgs(args...).
WithKubeconfig(kubeconfigPath).
Execute(ctx)
}
Changes:
- Add
-n kube-systemto thekubectl execcommand - Remove
-itflag (not needed for non-interactive execution, can cause TTY errors)
Environment
- kagent-tools chart version: 0.1.2
- kagent-tools deployed in namespace:
kagent-tools - Cilium pods running in:
kube-system
- Dominant language
- Go
- Stars
- 35
- Forks
- 30
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from kagent-dev/tools
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
kagent-dev/tools#84 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
kagent-dev/tools#82 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
kagent-dev/tools#80 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
kagent-dev/tools#69 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
kagent-dev/tools#68 · 1 comment ·
All issues in kagent-dev/tools
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
enhancement needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
kind/cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kubernetes-sigs/kueue#15947 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
sympozium-ai/sympozium#627 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100