replicaset_create
Create and manage Kubernetes ReplicaSets in specified namespaces using context, name, image, replicas, and labels for precise deployment scaling.
Instructions
Create a ReplicaSet in the specified namespace.
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The ReplicaSet name image: The container image to use replicas: Number of replicas labels: Labels to apply to the ReplicaSet
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/replicaset.py:27-58 (handler)The handler function for the 'replicaset_create' tool. It creates a Kubernetes ReplicaSet using the AppsV1Api, with the specified parameters. Decorated with @mcp.tool() for registration, @use_current_context for context management, and @check_readonly_permission (though it's a create operation). The function signature defines the input schema via type hints.@mcp.tool() @use_current_context @check_readonly_permission def replicaset_create(context_name: str, namespace: str, name: str, image: str, replicas: int, labels: dict): """ Create a ReplicaSet in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The ReplicaSet name image: The container image to use replicas: Number of replicas labels: Labels to apply to the ReplicaSet Returns: Status of the creation operation """ apps_v1: AppsV1Api = get_api_clients(context_name)["apps"] replicaset = V1ReplicaSet( metadata=V1ObjectMeta(name=name, labels=labels), spec={ "replicas": replicas, "selector": V1LabelSelector(match_labels=labels), "template": V1PodTemplateSpec( metadata=V1ObjectMeta(labels=labels), spec=V1PodSpec(containers=[V1Container(name=name, image=image)]) ) } ) created_replicaset = apps_v1.create_namespaced_replica_set(namespace=namespace, body=replicaset) return {"name": created_replicaset.metadata.name, "status": "Created"}