Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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)}`;
    }
  • 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: {} },
    },
  • The switch-case entry that calls the 'getNodes' handler function.
    case "k8s_get_nodes": return getNodes();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/batu-sonmez/infraclaude'

If you have feedback or need assistance with the MCP directory API, please join our Discord server