Skip to main content
Glama

k8s_rollback_deployment

Rollback a Kubernetes deployment to its previous revision to address issues or restore stability after problematic updates.

Instructions

Rollback a deployment to the previous revision

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesDeployment name
namespaceNoKubernetes namespace (default: 'default')

Implementation Reference

  • The handler function `rollbackDeployment` implements the rollback logic by patching the deployment's template with a `restartedAt` annotation to trigger a rollout.
    export async function rollbackDeployment(args: Record<string, unknown>): Promise<string> {
      const api = getAppsV1Api();
      const namespace = (args.namespace as string) || "default";
      const name = args.name as string;
    
      if (!name) throw new Error("Deployment name is required");
    
      // Rollback by patching the deployment to restart
      // In modern K8s, rollback is done via revision in rollout history
      const patch = {
        spec: {
          template: {
            metadata: {
              annotations: {
                "kubectl.kubernetes.io/restartedAt": new Date().toISOString(),
              },
            },
          },
        },
      };
    
      await api.patchNamespacedDeployment(
        name,
        namespace,
        patch,
        undefined,
        undefined,
        undefined,
        undefined,
        undefined,
        { headers: { "Content-Type": "application/strategic-merge-patch+json" } }
      );
    
      return `Deployment '${name}' in namespace '${namespace}' has been rolled back (restarted). Use k8s_rollout_status to monitor progress.`;
    }
  • The tool `k8s_rollback_deployment` is registered here with its input schema.
      name: "k8s_rollback_deployment",
      description: "Rollback a deployment to the previous revision",
      inputSchema: {
        type: "object" as const,
        properties: {
          name: { type: "string", description: "Deployment name" },
          namespace: { type: "string", description: "Kubernetes namespace (default: 'default')" },
        },
        required: ["name"],
      },
    },
  • The tool handler is routed to `rollbackDeployment` in the `handleKubernetesTool` function.
    case "k8s_rollback_deployment": return rollbackDeployment(a);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It implies a mutation ('Rollback') but doesn't disclose critical behaviors: whether it requires admin permissions, if it's destructive to current deployment state, potential downtime, rate limits, or what happens on success/failure. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—front-loaded with the core action and resource. Every word earns its place, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a mutation tool with no annotations and no output schema, the description is incomplete. It lacks behavioral details (e.g., side effects, error handling) and output expectations, which are crucial for safe agent operation in a Kubernetes context with siblings like k8s_delete_pod.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear parameter docs in the schema. The description adds no parameter-specific information beyond implying 'deployment' relates to the 'name' parameter. Baseline 3 is appropriate as the schema handles parameter semantics effectively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Rollback') and target resource ('a deployment'), specifying it goes 'to the previous revision'. It distinguishes from siblings like k8s_scale_deployment or k8s_get_deployments by focusing on revision reversal, though it doesn't explicitly contrast them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a previous revision), exclusions, or related tools like k8s_rollout_status for monitoring rollbacks, leaving the agent to infer usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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