statefulset_update
Update Kubernetes StatefulSets by modifying container images and replica counts for application deployment management.
Instructions
Update an existing StatefulSet in the specified namespace.
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The StatefulSet name image: The new container image to update replicas: The new number of replicas
Returns: Status of the update operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| namespace | Yes | ||
| name | Yes | ||
| image | Yes | ||
| replicas | Yes |
Implementation Reference
- tools/statefulset.py:86-108 (handler)The handler function for the 'statefulset_update' tool. It reads the existing StatefulSet, updates the container image and replicas count, then replaces it using the Kubernetes AppsV1Api. Registered via @mcp.tool() decorator.@mcp.tool() @use_current_context @check_readonly_permission def statefulset_update(context_name: str, namespace: str, name: str, image: str, replicas: int): """ Update an existing StatefulSet in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The StatefulSet name image: The new container image to update replicas: The new number of replicas Returns: Status of the update operation """ apps_v1: AppsV1Api = get_api_clients(context_name)["apps"] statefulset = apps_v1.read_namespaced_stateful_set(name=name, namespace=namespace) statefulset.spec.template.spec.containers[0].image = image statefulset.spec.replicas = replicas updated_statefulset = apps_v1.replace_namespaced_stateful_set(name=name, namespace=namespace, body=statefulset) return {"name": updated_statefulset.metadata.name, "status": "Updated"}