Repository navigation
feat(kagent): mount kagent tools and substrate MCP in the template - #472
Conversation
The AgentTemplate gave pi-go no tools beyond its own, so on kagent it could not inspect the cluster or the Substrate it runs on, and the github-egress policy blocked GitHub release downloads and kubectl. - AgentTemplate: mount kagent's two built-in MCP servers, kagent-tool-server (Kubernetes, Helm, Istio, Cilium, Argo Rollouts, Prometheus, shell) and kagent-api (Agent Substrate sandboxes, sessions, checkpoints). - New EgressPolicy pi-go-tools-egress: the two in-cluster MCP origins and https://dl.k8s.io. A BYO actor resolves and reaches only the hostnames its policies name, so without it the tools cannot connect. - github-egress: add https://release-assets.githubusercontent.com, where github.com/.../releases/download now redirects. - render-manifests.sh: --tool-server, --api-server, --tools-service and --tools-egress-name, defaulting to the kagent Helm chart's names. Verified on kagent v1.0.0-alpha17-76 with the same objects applied by hand: pi-go listed ate-system pods with k8s_get_resources and sandboxes with list_sandboxes; an actor downloaded kubectl v1.35.0 from dl.k8s.io and a release asset through release-assets.githubusercontent.com. Signed-off-by: pi <dimetron@me.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #472 +/- ##
==========================================
- Coverage 91.60% 91.59% -0.01%
==========================================
Files 390 390
Lines 50146 50146
==========================================
- Hits 45937 45933 -4
- Misses 4203 4207 +4
Partials 6 6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add pi-go-devtools-egress, which lists download hosts project by project instead of wildcards: - Kubernetes: dl.k8s.io and the kubernetes / kubernetes-sigs chart repos - kagent and Agent Substrate: kagent.dev, ghcr.io - agentgateway: agentgateway.dev, cr.agentgateway.dev - registry layers: pkg-containers.githubusercontent.com (ghcr.io and cr.agentgateway.dev both answer blob requests with a 307 there) - Helm: get.helm.sh - arkade: get.arkade.dev, the non-GitHub hosts `arkade get` downloads from (pkg/get/tools.go) and the chart repositories `arkade install` uses (pkg/apps), 43 origins in all dl.k8s.io moves here from pi-go-tools-egress, which now holds only the in-cluster MCP servers. --devtools-egress-name names the policy. An origin grants its whole host, so github.com and ghcr.io cannot be narrowed to one organisation's paths with an EgressPolicy; DEPLOY.md says so. Verified from a kagent actor: every host group answered (registries with the expected 401 on /v2/), get.arkade.dev served its installer, and an ungranted host (example.org) did not resolve. Signed-off-by: pi <dimetron@me.com>
|
Updated per review: egress is now allowed per project, with arkade added.
Limit: an EgressPolicy origin grants a whole host, all paths. So Verified on kagent alpha17-76 / Substrate rc1, from a Claude Code actor using the same list:
|
What
The kagent manifest now gives pi-go Kubernetes and Agent Substrate tools, and the network access they and common downloads need.
kagent-tool-server: Kubernetes, Helm, Istio, Cilium, Argo Rollouts, Prometheus and a shell tool.kagent-api: the controller's MCP, for Agent Substrate sandboxes, sessions and checkpoints.pi-go-tools-egress: grants the two in-cluster MCP origins (http://kagent-tools.<ns>.svc.cluster.local:8084,http://<controller>.<ns>.svc.cluster.local:8083) andhttps://dl.k8s.iofor kubectl.github-egressaddshttps://release-assets.githubusercontent.com.github.com/<owner>/<repo>/releases/download/...now redirects there, so release downloads failed.render-manifests.shgets--tool-server,--api-server,--tools-serviceand--tools-egress-name. The defaults are the kagent chart's names, so the release workflow needs no change.Why
On kagent, a BYO actor can only resolve and reach the hostnames its EgressPolicies name; Substrate's DNS relay answers NXDOMAIN for everything else. So the template's MCP servers need their own grant, as GitHub MCP already has one.
Verified
This is on kagent
v1.0.0-alpha17-76/ Substrate1.0.0-rc1(kind, arm64), with the same objects applied by hand to thepi-gotemplate and Agent.k8s_get_resources(11 pods inate-system) andlist_sandboxes(0). The Agent reportedEgressPoliciesApplied=True,ResolvedRefs=TrueandReady=True, with a new revision prepared.kubectlv1.35.0 fromdl.k8s.ioand fetchedv0.4.1/kagent-manifests.yamlthrough therelease-assetsredirect (3411 bytes).render-manifests.sh --image …@sha256:… --no-envleaves no placeholders.kubectl apply --dry-run=serveraccepts the Harness, AgentTemplate and new policy.bash -nand shellcheck are clean.Notes
kagent-tool-serverruns as cluster-admin in the default chart, includingshell,k8s_delete_resourceandhelm_uninstall. Every agent on this template gets that power. Narrow it withtools:on the binding where a harness enforces selection, or with RBAC onkagent-tools.github-egressdoesn't apply on an existing cluster, and that's not new. A client-sidekubectl applyof the rendered manifest still fails withmetadata.resourceVersion: Invalid value: 0: must be specified for an update. The other objects apply.kubectl apply --server-side --dry-run=serveraccepted all four objects, butscripts/install-kagent.shdocuments a problem mixing apply modes on these CRDs, so this PR doesn't change how the manifest is applied.