create_deployment
Deploy containerized applications to Kubernetes by specifying name, image, namespace, and replica count for scalable cluster management.
Instructions
Create a Kubernetes deployment with specified name, image, namespace and replicas
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| image | Yes | ||
| namespace | No | default | |
| replicas | No |
Implementation Reference
- kubernetes.py:190-204 (handler)This is the handler function for the 'create_deployment' tool, decorated with @mcp.tool() which registers it in the FastMCP server. It uses kubectl to create a deployment with the given name, image, namespace, and replicas.@mcp.tool() 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)}"}