Skip to main content
Glama

replicaset_create

Create a Kubernetes ReplicaSet to maintain a specified number of pod replicas for application availability and scaling.

Instructions

Create a ReplicaSet in the specified namespace.

Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The ReplicaSet name image: The container image to use replicas: Number of replicas labels: Labels to apply to the ReplicaSet

Returns: Status of the creation operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_nameYes
namespaceYes
nameYes
imageYes
replicasYes
labelsYes

Implementation Reference

  • The handler function for the 'replicaset_create' tool. It creates a Kubernetes ReplicaSet with the given parameters using the Kubernetes AppsV1Api client. Includes decorators for MCP tool registration, context usage, and permission checks.
    @mcp.tool()
    @use_current_context
    @check_readonly_permission
    def replicaset_create(context_name: str, namespace: str, name: str, image: str, replicas: int, labels: dict):
        """
        Create a ReplicaSet in the specified namespace.
    
        Args:
            context_name: The Kubernetes context name
            namespace: The Kubernetes namespace
            name: The ReplicaSet name
            image: The container image to use
            replicas: Number of replicas
            labels: Labels to apply to the ReplicaSet
    
        Returns:
            Status of the creation operation
        """
        apps_v1: AppsV1Api = get_api_clients(context_name)["apps"]
        replicaset = V1ReplicaSet(
            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_replicaset = apps_v1.create_namespaced_replica_set(namespace=namespace, body=replicaset)
        return {"name": created_replicaset.metadata.name, "status": "Created"}
  • server/server.py:7-27 (registration)
    The load_modules function imports the tools.replicaset module (line 19), which executes the @mcp.tool decorators to register the 'replicaset_create' tool with the MCP server.
    def load_modules():
        import resources.contexts  # noqa: F401
        import tools.cluster  # noqa: F401
        import tools.configmap  # noqa: F401
        import tools.daemonset  # noqa: F401
        import tools.deployment  # noqa: F401
        import tools.ingress  # noqa: F401
        import tools.namespace  # noqa: F401
        import tools.node  # noqa: F401
        import tools.pod  # noqa: F401
        import tools.pv  # noqa: F401
        import tools.pvc  # noqa: F401
        import tools.replicaset  # noqa: F401
        import tools.role  # noqa: F401
        import tools.secret  # noqa: F401
        import tools.service  # noqa: F401
        import tools.serviceaccount  # noqa: F401
        import tools.statefulset  # noqa: F401
    
    
    load_modules()

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