create_deployment
Deploy Kubernetes applications by specifying name, image, namespace, and replica count. Simplifies cluster management within the MCP Kubernetes Server environment.
Instructions
Create a Kubernetes deployment with specified name, image, namespace and replicas
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image | Yes | ||
| name | Yes | ||
| namespace | No | default | |
| replicas | No |
Implementation Reference
- kubernetes.py:190-190 (registration)Registration of the 'create_deployment' tool using the @mcp.tool() decorator.@mcp.tool()
- kubernetes.py:191-204 (handler)The main handler function for the 'create_deployment' tool. It uses kubectl to create a deployment with the given parameters.async def create_deployment(name: str, image: str, namespace: str = "default", replicas: int = 1) -> dict: """Create a Kubernetes deployment with specified name, image, namespace and replicas""" try: # Apply the deployment cmd = ["kubectl", "create", "deploy", name, "--replicas", str(replicas), "--image", image, "-n", namespace] result = subprocess.run(cmd, capture_output=True, text=True, check=True) return {"message": f"Deployment {name} created successfully in namespace {namespace}", "details": result.stdout} except subprocess.CalledProcessError as e: return {"error": f"Failed to create deployment: {str(e)}"}