基于 GPT-4o 和 MCP 集成的对话式 Kubernetes 管理
中级
这是一个DevOps, AI领域的自动化工作流,包含 14 个节点。主要使用 McpClientTool, Agent, ChatTrigger, LmChatOpenAi, MemoryBufferWindow 等节点,结合人工智能技术实现智能自动化。 基于 GPT-4o 和 MCP 集成的对话式 Kubernetes 管理
前置要求
- •OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "66f06061721f1f7966ba3bdd29bb7db37d84222e0e73cbdc5057760193ad29bf",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "41c2617e-b606-473d-ac07-ac0c5901935a",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
400,
-80
],
"webhookId": "2eb47787-160f-49ad-b98d-1d8ee757765c",
"parameters": {
"options": {}
},
"typeVersion": 1.1
},
{
"id": "be64c331-8fb2-4efd-a10e-beb1938cdb71",
"name": "AI 代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
800,
-80
],
"parameters": {
"options": {
"systemMessage": "=You are a Kubernetes assistant connected to an MCP (Model Context Protocol) Server. Your role is to help users monitor, inspect, and troubleshoot Kubernetes resources using the following tools.\ncurrent time is {{ $now.setZone('Asia/Tehran') }}\n\nAvailable Tools:\n1. getEvents(namespace) – Fetch events in the given namespace.\n2. getPodsLogs(namespace, podName) – Retrieve logs for a specific pod.\n3. getResource(namespace, resourceKind, resourceName) – Get details of a specific resource.\n4. createOrUpdateResource(namespace, resourceYaml) – Create or update a resource using full YAML.\n5. getNodeMetrics(nodeName) – Retrieve CPU and memory usage of a node.\n6. getPodMetrics(namespace, podName) – Retrieve CPU and memory usage of a pod.\n7. describeResource(namespace, resourceKind, resourceName) – Detailed description of a resource.\n8. listResources(namespace, resourceKind) – List all resources of a given kind in a namespace. for example{\"Kind\": \"Pod\",\"namespace\": \"x\"}\n9. getAPIResources() – List all supported resource kinds in the cluster.\n\nUsage Rules:\n***keep your answers short and meaningful***\n- Always validate input arguments before calling any tool.\n- Ask the user for any missing information (e.g., namespace, podName, resourceKind).\n- Do not assume defaults; always confirm with the user.\n- Avoid destructive operations unless explicitly instructed (only createOrUpdateResource modifies the cluster).\n- Use getAPIResources() to help the user explore available resource kinds.\n- Respond with concise, plain-language explanations of the results when helpful.\n"
}
},
"typeVersion": 1.8
},
{
"id": "61247bd0-5e76-4165-af70-26c0d605d12f",
"name": "简单记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
340,
140
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "f8136d5d-c5db-4c4f-a080-ad65d5ef9aac",
"name": "MCP 客户端",
"type": "n8n-nodes-mcp.mcpClientTool",
"position": [
460,
260
],
"parameters": {
"connectionType": "sse"
},
"credentials": {
"mcpClientSseApi": {
"id": "eyJUyjbc2529AKLS",
"name": "k8s"
}
},
"typeVersion": 1
},
{
"id": "47eae87b-f2fa-46d5-9f77-d168e47e9bfe",
"name": "获取 API 资源",
"type": "n8n-nodes-mcp.mcpClientTool",
"position": [
580,
260
],
"parameters": {
"toolName": "getAPIResources",
"operation": "executeTool",
"connectionType": "sse",
"toolParameters": "{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"method\": \"getAPIResources\",\n \"params\": {\n \"arguments\": {\n \"includeNamespaceScoped\": true,\n \"includeClusterScoped\": true\n }\n }\n}"
},
"credentials": {
"mcpClientSseApi": {
"id": "eyJUyjbc2529AKLS",
"name": "k8s"
}
},
"typeVersion": 1
},
{
"id": "648eacf9-436d-44d6-9389-a0a5212071fa",
"name": "列出资源",
"type": "n8n-nodes-mcp.mcpClientTool",
"position": [
740,
260
],
"parameters": {
"toolName": "listResources",
"operation": "executeTool",
"connectionType": "sse",
"toolParameters": "={\"Kind\": \"{{ $fromAI('Kind', 'Select the kind given by ai agent', 'string') }}\",\n\"namespace\" : \"{{ $fromAI('namespace', 'Select the namespace given by ai agent', 'string') }}\"}"
},
"credentials": {
"mcpClientSseApi": {
"id": "eyJUyjbc2529AKLS",
"name": "k8s"
}
},
"typeVersion": 1
},
{
"id": "a62f3378-65fe-4178-9fba-b52ba437ca38",
"name": "描述资源",
"type": "n8n-nodes-mcp.mcpClientTool",
"position": [
900,
260
],
"parameters": {
"toolName": "describeResource",
"operation": "executeTool",
"connectionType": "sse",
"toolParameters": "={\"Kind\": \"{{ $fromAI('Kind', 'Select the kind given by ai agent', 'string') }}\",\n\"name\" : \"{{ $fromAI('name', 'Select the name given by ai agent', 'string') }}\",\n\"namespace\" : \"{{ $fromAI('namespace', 'Select the namespace given by ai agent', 'string') }}\"}"
},
"credentials": {
"mcpClientSseApi": {
"id": "eyJUyjbc2529AKLS",
"name": "k8s"
}
},
"typeVersion": 1
},
{
"id": "c159ae52-4963-4103-93ad-083230b46da3",
"name": "获取 Pod 指标",
"type": "n8n-nodes-mcp.mcpClientTool",
"position": [
1040,
260
],
"parameters": {
"toolName": "getPodMetrics",
"operation": "executeTool",
"connectionType": "sse",
"toolParameters": "={\"podName\" : \"{{ $fromAI('podName', 'Select the pod name given by ai agent', 'string') }}\",\n\"namespace\" : \"{{ $fromAI('namespace', 'Select the namespace given by ai agent', 'string') }}\"}"
},
"credentials": {
"mcpClientSseApi": {
"id": "eyJUyjbc2529AKLS",
"name": "k8s"
}
},
"typeVersion": 1
},
{
"id": "f49b0804-b15a-4a7d-ac9f-44f51795abdf",
"name": "获取节点指标",
"type": "n8n-nodes-mcp.mcpClientTool",
"position": [
1180,
260
],
"parameters": {
"toolName": "getNodeMetrics",
"operation": "executeTool",
"connectionType": "sse",
"toolParameters": "={\"Name\" : \"{{ $fromAI('Name', 'Select the name given by ai agent', 'string') }}\"}"
},
"credentials": {
"mcpClientSseApi": {
"id": "eyJUyjbc2529AKLS",
"name": "k8s"
}
},
"typeVersion": 1
},
{
"id": "decd4807-5dbe-4f65-8bd5-8401ee2b0154",
"name": "创建或更新资源",
"type": "n8n-nodes-mcp.mcpClientTool",
"position": [
1340,
240
],
"parameters": {
"toolName": "createResource",
"operation": "executeTool",
"connectionType": "sse",
"toolParameters": "={\"manifest\" : \"{{ $fromAI('manifest', 'Select the manifest given by ai agent', 'string').trim() }}\",\n\"namespace\" : \"{{ $fromAI('namespace', 'Select the namespace given by ai agent', 'string') }}\"}"
},
"credentials": {
"mcpClientSseApi": {
"id": "eyJUyjbc2529AKLS",
"name": "k8s"
}
},
"typeVersion": 1
},
{
"id": "1b1bc11c-565e-46f7-8b38-e74489ea2372",
"name": "获取资源",
"type": "n8n-nodes-mcp.mcpClientTool",
"position": [
1440,
140
],
"parameters": {
"toolName": "getResource",
"operation": "executeTool",
"connectionType": "sse",
"toolParameters": "={\"kind\": \"{{ $fromAI('kind', 'Select the kind given by ai agent', 'string') }}\",\n\"name\" : \"{{ $fromAI('name', 'Select the name given by ai agent', 'string') }}\",\n\"namespace\" : \"{{ $fromAI('namespace', 'Select the namespace given by ai agent', 'string') }}\"}"
},
"credentials": {
"mcpClientSseApi": {
"id": "eyJUyjbc2529AKLS",
"name": "k8s"
}
},
"typeVersion": 1
},
{
"id": "f34b5527-c048-4e6e-b86a-585a586ef8ff",
"name": "获取 Pods 日志",
"type": "n8n-nodes-mcp.mcpClientTool",
"position": [
1420,
-20
],
"parameters": {
"toolName": "getPodsLogs",
"operation": "executeTool",
"connectionType": "sse",
"toolParameters": "={\"Name\" : \"{{ $fromAI('Name', 'Select the name given by ai agent', 'string') }}\",\n\"namespace\" : \"{{ $fromAI('namespace', 'Select the namespace given by ai agent', 'string') }}\"}"
},
"credentials": {
"mcpClientSseApi": {
"id": "eyJUyjbc2529AKLS",
"name": "k8s"
}
},
"typeVersion": 1
},
{
"id": "68234560-f7f9-4a6a-9579-497ff458fedc",
"name": "获取事件",
"type": "n8n-nodes-mcp.mcpClientTool",
"position": [
1340,
-160
],
"parameters": {
"toolName": "getEvents",
"operation": "executeTool",
"connectionType": "sse",
"toolParameters": "={\n\"namespace\" : \"{{ $fromAI('namespace', 'Select the namespace given by ai agent', 'string') }}\"}"
},
"credentials": {
"mcpClientSseApi": {
"id": "eyJUyjbc2529AKLS",
"name": "k8s"
}
},
"typeVersion": 1
},
{
"id": "9a20f489-799e-44aa-a6cd-2f68814113a6",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
220,
140
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"maxTokens": -1
}
},
"credentials": {
"openAiApi": {
"id": "CvwUuKPhahoMTR21",
"name": "OpenAi play ground"
}
},
"typeVersion": 1.2
}
],
"pinData": {},
"connections": {
"getEvents": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"MCP Client": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"getPodsLogs": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"getResource": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"getPodMetrics": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"listResources": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"getNodeMetrics": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"getAPIResources": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"describeResource": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"createorUpdateResource": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 开发运维, 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
数据分析师 Agent v3
用于电子表格的AI数据分析助手,基于NocoDB平台
Set
Noco Db Tool
Http Request
+5
10 节点Derek Cheung
工程
仅从数据库架构生成 SQL 查询 - AI 驱动
仅从数据库架构生成 SQL 查询 - AI 驱动
If
Set
Merge
+11
29 节点Yulia
工程
使用OpenAI和Quickchart.io可视化SQL代理查询
使用OpenAI和Quickchart.io可视化SQL代理查询
Set
Http Request
Agent
+7
16 节点Agent Studio
工程
我的工作流
使用Bright Data网络爬取和GPT-4.1生成个人新闻源
Set
Email Send
Mcp Client Tool
+6
15 节点Daniel Shashko
其他
与Supabase存储中文件对话的AI智能体
与Supabase存储中文件对话的AI智能体
If
Merge
Switch
+15
33 节点Mark Shcherbakov
工程
与Supabase-PostgreSQL数据库对话的AI智能体
用于与Supabase/PostgreSQL数据库对话的AI智能体
Postgres Tool
Agent
Tool Code
+3
11 节点Mark Shcherbakov
工程
工作流信息
难度等级
中级
节点数量14
分类2
节点类型5
作者
Reza Gholizade
@reza-gholizadeI'm a seasoned Solution Architect with expertise in designing and implementing complex, scalable systems across various platforms. With a strong foundation in cloud infrastructure, microservices architecture, Kubernetes, and DevOps practices, they specialize in creating innovative solutions using cutting-edge technologies and tools.
外部链接
在 n8n.io 查看 →
分享此工作流