最新资讯
dev.to 我们在 DolphinBench 上测试记忆检索:纯关键词搜索暴露了自身回归 dev.to 别再把 Agent 写成 while 循环,把它建模为状态机 bloomberg.com Rightmove 与 Scout24 借 AI 产品应对低迷房市并上调展望 stackoverflow.blog 欢迎来到芯片时代:半导体制造、AI 数据中心与芯片设计的未来 www.youtube.com AI Agent 总犯同样的错:CentralAgent AI 将记忆重构为经验系统 pub.towardsai.net Netflix 科学家建议重采样 LLM 评判:5 次仅将误差棒缩小 13% pub.towardsai.net Jev 作为 LLM 前的静默层:构建提示感知的模型路由器 reddit.com OpenAI 称 Astra 仅满足 10% 安全任务标准 dev.to FreeToken:在自有 GPU 上运行前沿 MoE 模型及其内存需求 dev.to 当 AI Agent 说“完成”时,究竟完成了什么? dev.to 部署 Underdog Bark 3.0 Pro:逐字转写、自定义后端与分块设置 dev.to 为艰难对话构建 AI:五个 Agent、一条安全正则与一位盲评监督者
多元动态
登录 注册
大模型 dev.to · @Sanskriti Harmukh

使用 K8s MCP Server 管理 Kubernetes 集群

原文 我的收藏

文章介绍如何运行 Kubernetes MCP Server 容器,并将其接入 Claude Desktop,从而用自然语言与 Kubernetes 集群交互、以对话方式管理集群。文中说明 MCP 通过定义用户意图、记忆和可用工具来为 LLM 组织上下文,并列出前置条件:已部署的 K8s 集群、kubectl、kubeconfig 文件以及 Claude Desktop 和 Docker Desktop。

AI推荐理由 将 MCP 与 Kubernetes 结合的实操指南,演示用自然语言通过 Claude Desktop 管理集群,体现 Agent 与开发运维工具链的落地路径。步骤具体、可复现,对关注 MCP 生态和 AI 运维的开发者有实际参考价值。

66

正文

Model Context Protocol (MCP) is a new approach to organizing context for large language models, letting them act more intelligently and maintain continuity across tasks, tools, and sessions. By defining key elements like user intent, memory, and available tools, MCP enables more seamless, context-aware interactions in AI applications. This guide walks through running a Kubernetes MCP server container so you can interact with a Kubernetes cluster using natural language, and shows how to connect it to Claude Desktop to manage the cluster conversationally. By the end, you'll have a Kubernetes MCP server running locally and wired into Claude Desktop for natural-language cluster management. Prerequisites Before you begin: Deploy a Kubernetes cluster. Install kubectl. Download your cluster's kubeconfig file. Download the Claude Desktop application. Download the Docker Desktop application. Get Started Right Away Make sure you've downloaded your Kubernetes cluster's kubeconfig file to your local system before proceeding. 1. Display all available contexts defined in the kubeconfig file: $ kubectl config get-contexts Enter fullscreen mode Exit fullscreen mode Copy the context value to use in the later steps. 2. Pull the sample Kubernetes MCP server Docker container image: $ docker pull ghcr.io/alexei-led/k8s-mcp-server:latest Enter fullscreen mode Exit fullscreen mode 3. Run the sample Kubernetes MCP server Docker container image: $ docker run -i --rm \ -v ~/.kube:/home/appuser/.kube:ro \ -e K8S_CONTEXT= \ ghcr.io/alexei-led/k8s-mcp-server:latest Enter fullscreen mode Exit fullscreen mode 4. Confirm the image is running in the Docker Desktop application. Understand the MCP Server Unified Kubernetes CLI Tools — built-in support for multiple Kubernetes tools like kubectl, helm, istioctl, and argocd, all within a single containerized environment. Cloud-Native Integration — native compatibility with major managed Kubernetes providers. Secure by Design — runs as a non-root user and enforces strict validation on incoming commands to maintain security and control. Flexible Command Chaining — supports command piping and integrates smoothly with Unix utilities like jq, grep, and sed for complex workflows. Simplified Configuration — easily customizable through environment variables, minimizing setup time and complexity. Use Claude Desktop to Interact The Claude Desktop application automatically detects MCP servers defined in its configuration file and makes them accessible within any conversation. 1. Start the Claude Desktop application. 2. Locate the settings option in the application. 3. Select Developer settings. 4. Click Edit Config. 5. Add the following configuration snippet to your Claude Desktop config file: { "mcpServers": { "kubernetes": { "command": "docker", "args": [ "run", "-i", "--rm", "-v", "/Users/YOUR_USER_NAME/.kube:/home/appuser/.kube:ro", "-e", "K8S_CONTEXT=", "ghcr.io/alexei-led/k8s-mcp-server:latest" ] } } } Enter fullscreen mode Exit fullscreen mode Replace the value of K8S_CONTEXT with your actual Kubernetes context name. Also update the mount path /Users/YOUR_USER_NAME/.kube to point to your real .kube directory (usually ~/.kube on most systems). 6. Restart the Claude Desktop application once the new configuration is in place. 7. Confirm the server is running: go to the Developer settings in Claude Desktop and check that the status next to the JSON file shows as running. 8. Make sure the MCP server tools are available to the application. Ask Questions and Perform Operations You can manage your Kubernetes cluster by chatting naturally using the Claude Desktop application. Make sure the responses match the actual state of your cluster. Example Operations Supported by the Kubernetes MCP Server Advanced Operations Check the status of the Istio service mesh. Create an ArgoCD application for a repository. Deployments & Configuration Deploy the Nginx Helm chart. Create a deployment with 3 replicas of nginx:latest. Set up an Ingress controller. Troubleshooting Describe the failing pod and explain the error. Check if a service is properly connected to its pods. Basic Commands Show all pods in the default namespace. Get all services across all namespaces. Display the logs for the Nginx pod. Next Steps Extend the MCP server configuration to manage multiple cluster contexts side by side. Pair the MCP server with the ArgoCD and Istio tooling already built into the container. Explore additional natural-language operations for scaling, troubleshooting, and Helm deployments. For the full guide with additional tips, visit the original article on Vultr Docs.

来源报道 · 1 篇 · 以下链接均前往原始媒体

Sanskriti Harmukh 使用 K8s MCP Server 管理 Kubernetes 集群 09-17 · 原文发布
← 返回精选动态 原文

更多内容