feat: in-cluster config support + cluster observability tools#109
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for running kai inside a Kubernetes cluster using in-cluster configuration. This enables the application to authenticate using the service account mounted in the pod, eliminating the need for external kubeconfig files when deployed in-cluster.
Changes:
- Added a new
-in-clustercommand-line flag to enable in-cluster configuration mode - Implemented
LoadInClusterConfigmethod to configure Kubernetes clients using in-cluster authentication - Added comprehensive test coverage for the new in-cluster configuration functionality
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmd/kai/main.go | Added -in-cluster flag and conditional logic to load either in-cluster or kubeconfig-based configuration |
| cluster/manager.go | Implemented LoadInClusterConfig method with client creation, connection testing, and context management |
| cluster/manager_test.go | Added test suite covering edge cases including duplicate context names and default naming behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@basebandit I've opened a new pull request, #110, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@basebandit I've opened a new pull request, #111, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@basebandit I've opened a new pull request, #112, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@basebandit I've opened a new pull request, #113, to work on those changes. Once the pull request is ready, I'll request review from you. |
4a2c802 to
26d7120
Compare
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e46f970 to
1bb7de5
Compare
7acc774 to
22ba5d7
Compare
Add list_events with namespace, type, and involved-object filtering. Add node management tools: - list_nodes - get_node - cordon_node - uncordon_node - drain_node Drain operations use the eviction API and skip DaemonSet and mirror pods. Add cluster_health for node readiness and pod phase summaries. Add node_metrics and pod_metrics using the metrics.k8s.io API through the dynamic client, with graceful degradation when metrics-server is unavailable. Annotate tools with MCP metadata (read-only, destructive, idempotent) and add fake-client unit tests and tool registration tests.
SonarCloud quality gate failed: new code coverage was 50.9% (< 80%). The new event/node/health tool handlers and several cluster paths (health metrics, node Get/Drain, event timestamp fallbacks) lacked direct tests, and CI measures coverage per-package so registration tests did not count. Add fake-client tests covering the tool handlers end-to-end plus the cluster-level node metrics, drain (skip + eviction) and event formatting paths. New-file coverage now ~90% (cluster 80.2%, tools 85.8%).
22ba5d7 to
5c41a99
Compare
|





Description
Production-readiness work, rebased on top of the MCP 2025-06-18 modernization (#123). Two related feature sets:
In-cluster Kubernetes configuration
-in-clusterflag uses the pod service account credentials when running inside the cluster.rest.Configstored per context so port-forwarding works under in-cluster config.LoadInClusterConfig+ docs.Cluster observability & node management (9 new tools)
list_events(filter by namespace, type, involved object).list_nodes,get_node,cordon_node,uncordon_node,drain_node(evicts via the eviction API; skips DaemonSet and mirror pods).cluster_health(node readiness + pod phase summary),node_metrics,pod_metrics(query metrics.k8s.io via the dynamic client; degrade gracefully when metrics-server is absent).Type of change
Tests
go build ./...,go vet ./...,go test ./...all green.Follow-ups (separate PRs)
deploy/manifests + RBACChecklist: