statefulset_create
Create a StatefulSet in Kubernetes to deploy and manage stateful applications with persistent storage and stable network identities.
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 | ||
| namespace | Yes | ||
| name | Yes | ||
| image | Yes | ||
| replicas | Yes | ||
| labels | Yes |
Implementation Reference
- tools/statefulset.py:27-59 (handler)The statefulset_create tool handler function, registered via @mcp.tool() decorator. It creates a Kubernetes StatefulSet in the specified namespace using the provided parameters, leveraging Kubernetes Python client APIs.@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"}