Skip to main content
Glama

k8s_get_deployments

Retrieve Kubernetes deployment details including replica status, strategy, and age for infrastructure management and monitoring.

Instructions

List deployments with replica status, strategy, and age

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
namespaceNoKubernetes namespace (default: 'default')
label_selectorNoLabel selector to filter

Implementation Reference

  • The `getDeployments` function, which fetches and formats Kubernetes deployments from a given namespace.
    export async function getDeployments(args: Record<string, unknown>): Promise<string> {
      const api = getAppsV1Api();
      const namespace = (args.namespace as string) || "default";
      const labelSelector = args.label_selector as string | undefined;
    
      const response = await api.listNamespacedDeployment(
        namespace,
        undefined,
        undefined,
        undefined,
        undefined,
        labelSelector
      );
    
      const deployments = response.body.items;
      if (deployments.length === 0) {
        return `No deployments found in namespace '${namespace}'.`;
      }
    
      const headers = ["NAME", "READY", "UP-TO-DATE", "AVAILABLE", "AGE", "STRATEGY"];
      const rows = deployments.map((dep) => {
        const ready = dep.status?.readyReplicas || 0;
        const desired = dep.spec?.replicas || 0;
        const upToDate = dep.status?.updatedReplicas || 0;
        const available = dep.status?.availableReplicas || 0;
        const age = dep.metadata?.creationTimestamp
          ? formatAge(dep.metadata.creationTimestamp)
          : "?";
        const strategy = dep.spec?.strategy?.type || "RollingUpdate";
    
        return [
          dep.metadata?.name || "unknown",
          `${ready}/${desired}`,
          String(upToDate),
          String(available),
          age,
          strategy,
        ];
      });
    
      return `Deployments in namespace '${namespace}':\n\n${formatTable(headers, rows)}`;
    }
  • The registration point in the switch statement for the `k8s_get_deployments` tool.
    case "k8s_get_deployments": return getDeployments(a);

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