k8s_top_nodes
Monitor CPU and memory utilization across all Kubernetes cluster nodes to identify resource bottlenecks and optimize infrastructure performance.
Instructions
Show CPU and memory usage for all cluster nodes (requires metrics-server)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/kubernetes/resources.ts:48-72 (handler)The implementation of the `k8s_top_nodes` handler function, which fetches node resource metrics using the metrics API.
export async function topNodes(): Promise<string> { const api = getMetricsApi(); const response = await api.listClusterCustomObject( "metrics.k8s.io", "v1beta1", "nodes" ); const body = response.body as { items: MetricsItem[] }; const items = body.items || []; if (items.length === 0) { return "No metrics available for nodes. Is metrics-server installed?"; } const headers = ["NODE", "CPU", "MEMORY"]; const rows = items.map((item) => [ item.metadata.name, item.usage?.cpu || "N/A", item.usage?.memory || "N/A", ]); return `Node resource usage:\n\n${formatTable(headers, rows)}`; } - src/tools/kubernetes/index.ts:86-90 (registration)Tool registration for `k8s_top_nodes` in the Kubernetes toolset.
{ name: "k8s_top_nodes", description: "Show CPU and memory usage for all cluster nodes (requires metrics-server)", inputSchema: { type: "object" as const, properties: {} }, }, - src/tools/kubernetes/index.ts:202-202 (handler)Tool handler delegation for `k8s_top_nodes`.
case "k8s_top_nodes": return topNodes();