secret_update
Update Kubernetes Secrets in a specified namespace using key-value pairs, with values automatically encoded. Operates via the k8s-pilot MCP server for streamlined multi-cluster management.
Instructions
Update an existing Secret in the specified namespace.
Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Secret name data: A dictionary of key-value pairs (values will be base64 encoded)
Returns: Status of the update operation
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context_name | Yes | ||
| data | Yes | ||
| name | Yes | ||
| namespace | Yes |
Implementation Reference
- tools/secret.py:80-101 (handler)The handler function for the 'secret_update' MCP tool, decorated with @mcp.tool() for registration. It updates an existing Kubernetes Secret by reading it, encoding new data, updating the data field, and replacing the secret.@mcp.tool() @use_current_context @check_readonly_permission def secret_update(context_name: str, namespace: str, name: str, data: dict): """ Update an existing Secret in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Secret name data: A dictionary of key-value pairs (values will be base64 encoded) Returns: Status of the update operation """ core_v1: CoreV1Api = get_api_clients(context_name)["core"] secret = core_v1.read_namespaced_secret(name=name, namespace=namespace) encoded_data = {key: base64.b64encode(value.encode()).decode() for key, value in data.items()} secret.data.update(encoded_data) updated_secret = core_v1.replace_namespaced_secret(name=name, namespace=namespace, body=secret) return {"name": updated_secret.metadata.name, "status": "Updated"}
- tools/secret.py:80-80 (registration)The @mcp.tool() decorator registers the secret_update function as an MCP tool.@mcp.tool()
- tools/secret.py:84-94 (schema)Docstring providing input schema (parameters) and output description for the secret_update tool.""" Update an existing Secret in the specified namespace. Args: context_name: The Kubernetes context name namespace: The Kubernetes namespace name: The Secret name data: A dictionary of key-value pairs (values will be base64 encoded) Returns: Status of the update operation