statefulset_create
Create a StatefulSet in a specified Kubernetes namespace using the k8s-pilot MCP server. Define context, namespace, image, replicas, and labels to manage deployment configurations.
Instructions
Create a StatefulSet in the specified namespace.
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The StatefulSet name image: The container image to use replicas: Number of replicas labels: Labels to apply to the StatefulSet
Returns: Status of the creation operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| image | Yes | ||
| labels | Yes | ||
| name | Yes | ||
| namespace | Yes | ||
| replicas | Yes |
Implementation Reference
- tools/statefulset.py:27-59 (handler)The statefulset_create function decorated with @mcp.tool() implements and registers the MCP tool for creating a Kubernetes StatefulSet. It uses Kubernetes client to create the StatefulSet object and applies it to the specified namespace.@mcp.tool() @use_current_context @check_readonly_permission def statefulset_create(context_name: str, namespace: str, name: str, image: str, replicas: int, labels: dict): """ Create a StatefulSet in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The StatefulSet name image: The container image to use replicas: Number of replicas labels: Labels to apply to the StatefulSet Returns: Status of the creation operation """ apps_v1: AppsV1Api = get_api_clients(context_name)["apps"] statefulset = V1StatefulSet( metadata=V1ObjectMeta(name=name, labels=labels), spec=V1StatefulSetSpec( replicas=replicas, selector=V1LabelSelector(match_labels=labels), service_name=name, template=V1PodTemplateSpec( metadata=V1ObjectMeta(labels=labels), spec=V1PodSpec(containers=[V1Container(name=name, image=image)]) ) ) ) created_statefulset = apps_v1.create_namespaced_stateful_set(namespace=namespace, body=statefulset) return {"name": created_statefulset.metadata.name, "status": "Created"}
- tools/statefulset.py:27-27 (registration)The @mcp.tool() decorator registers the statefulset_create function as an MCP tool.@mcp.tool()