Skip to main content
Glama

service_create

Create Kubernetes Services in specified namespaces using context name, labels, ports, and service type. Simplify resource management on the k8s-pilot MCP server.

Instructions

Create a Service in the specified namespace.

Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Service name selector: A dictionary of labels to select the target pods ports: A list of ports (e.g., [{"port": 80, "target_port": 8080}]) service_type: The type of the Service (default is "ClusterIP")

Returns: Status of the creation operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
nameYes
namespaceYes
portsYes
selectorYes
service_typeNoClusterIP

Implementation Reference

  • The main handler function for the 'service_create' MCP tool. It creates a Kubernetes Service using the provided parameters, decorated with @mcp.tool() for registration and other decorators for context and permissions.
    @use_current_context @check_readonly_permission def service_create(context_name: str, namespace: str, name: str, selector: dict, ports: list, service_type: str = "ClusterIP"): """ Create a Service in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Service name selector: A dictionary of labels to select the target pods ports: A list of ports (e.g., [{"port": 80, "target_port": 8080}]) service_type: The type of the Service (default is "ClusterIP") Returns: Status of the creation operation """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] service = V1Service( metadata=V1ObjectMeta(name=name), spec=V1ServiceSpec( selector=selector, ports=[V1ServicePort(port=port["port"], target_port=port["target_port"]) for port in ports], type=service_type ) ) created_service = core_v1.create_namespaced_service(namespace=namespace, body=service) return {"name": created_service.metadata.name, "status": "Created"}

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bourbonkk/k8s-pilot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server