k8s_get_nodes
Retrieve Kubernetes cluster node details including status, roles, and version information to monitor infrastructure health and configuration.
Instructions
List all cluster nodes with status, roles, and version
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/kubernetes/nodes.ts:4-37 (handler)The getNodes function fetches the list of nodes from the Kubernetes API and formats them into a table string.
export async function getNodes(): Promise<string> { const api = getCoreV1Api(); const response = await api.listNode(); const nodes = response.body.items; if (nodes.length === 0) { return "No nodes found in the cluster."; } const headers = ["NAME", "STATUS", "ROLES", "AGE", "VERSION"]; const rows = nodes.map((node) => { const conditions = node.status?.conditions || []; const readyCond = conditions.find((c) => c.type === "Ready"); const status = readyCond?.status === "True" ? "Ready" : "NotReady"; const roles = Object.keys(node.metadata?.labels || {}) .filter((l) => l.startsWith("node-role.kubernetes.io/")) .map((l) => l.replace("node-role.kubernetes.io/", "")) .join(",") || "<none>"; // Check for taints that indicate scheduling issues const unschedulable = node.spec?.unschedulable ? ",SchedulingDisabled" : ""; return [ node.metadata?.name || "unknown", status + unschedulable, roles, node.metadata?.creationTimestamp ? formatAge(node.metadata.creationTimestamp) : "?", node.status?.nodeInfo?.kubeletVersion || "?", ]; }); return `Cluster nodes:\n\n${formatTable(headers, rows)}`; } - src/tools/kubernetes/index.ts:150-153 (registration)The tool definition for 'k8s_get_nodes' in the registration list.
name: "k8s_get_nodes", description: "List all cluster nodes with status, roles, and version", inputSchema: { type: "object" as const, properties: {} }, }, - src/tools/kubernetes/index.ts:208-208 (handler)The switch-case entry that calls the 'getNodes' handler function.
case "k8s_get_nodes": return getNodes();