pod_create
Create Kubernetes pods in specified namespaces with customizable container images, commands, labels, and environment variables using k8s-pilot's centralized control plane.
Instructions
Create a new pod in the specified namespace.
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The name for the new pod image: The container image to use labels: Optional dictionary of pod labels command: Optional command to run in the container args: Optional arguments for the command env_vars: Optional environment variables for the container
Returns: Information about the created pod
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | ||
| command | No | ||
| context_name | Yes | ||
| env_vars | No | ||
| image | Yes | ||
| labels | No | ||
| name | Yes | ||
| namespace | Yes |
Implementation Reference
- tools/pod.py:176-240 (handler)The @mcp.tool()-decorated handler function that implements the pod_create tool, creating a Kubernetes pod with the specified name, image, labels, command, args, and env_vars in the given namespace and context.@mcp.tool() @use_current_context @check_readonly_permission def pod_create(context_name: str, namespace: str, name: str, image: str, labels: Optional[Dict[str, str]] = None, command: Optional[List[str]] = None, args: Optional[List[str]] = None, env_vars: Optional[Dict[str, str]] = None): """ Create a new pod in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The name for the new pod image: The container image to use labels: Optional dictionary of pod labels command: Optional command to run in the container args: Optional arguments for the command env_vars: Optional environment variables for the container Returns: Information about the created pod """ from kubernetes.client import V1Pod, V1ObjectMeta, V1PodSpec, V1Container, V1EnvVar core_v1: CoreV1Api = get_api_clients(context_name)["core"] # Prepare environment variables if provided container_env = None if env_vars: container_env = [V1EnvVar(name=k, value=v) for k, v in env_vars.items()] # Create container container = V1Container( name=name, image=image, command=command, args=args, env=container_env ) # Create pod spec pod_spec = V1PodSpec(containers=[container]) # Create pod metadata pod_metadata = V1ObjectMeta(name=name, namespace=namespace, labels=labels) # Create pod pod = V1Pod( api_version="v1", kind="Pod", metadata=pod_metadata, spec=pod_spec ) # Create the pod in Kubernetes created_pod = core_v1.create_namespaced_pod(namespace=namespace, body=pod) result = { "name": created_pod.metadata.name, "namespace": created_pod.metadata.namespace, "status": "Created", } return result