deployment_create
Create Kubernetes deployments in specified namespaces to manage containerized applications with defined replicas, images, and labels.
Instructions
Create a Deployment in the specified namespace.
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Deployment name image: The container image to use replicas: Number of replicas labels: Labels to apply to the Deployment
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/deployment.py:27-58 (handler)The main handler function for the 'deployment_create' tool. It is decorated with @mcp.tool() which registers it as an MCP tool. The function creates a Kubernetes Deployment in the specified namespace using the provided parameters.@mcp.tool() @use_current_context @check_readonly_permission def deployment_create(context_name: str, namespace: str, name: str, image: str, replicas: int, labels: dict): """ Create a Deployment in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Deployment name image: The container image to use replicas: Number of replicas labels: Labels to apply to the Deployment Returns: Status of the creation operation """ apps_v1: AppsV1Api = get_api_clients(context_name)["apps"] deployment = V1Deployment( 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_deployment = apps_v1.create_namespaced_deployment(namespace=namespace, body=deployment) return {"name": created_deployment.metadata.name, "status": "Created"}