100 个 Agent Skills 盘点(五):云服务与 DevOps

2822 字
14 分钟
100 个 Agent Skills 盘点(五):云服务与 DevOps

封面
封面

写在前面#

这是「100 个 Agent Skills 盘点」系列的第五篇。前面讲了代码审查、数据库、浏览器、搜索,这一篇进入”基建层”——云服务与 DevOps。

为什么 DevOps Skills 对 Agent 至关重要?

因为代码写完只是开始,部署上线才是真正的价值交付。一个不懂 DevOps 的 Agent,就像一个会做饭但不会端盘子的厨师——手艺再好,客户也吃不到。


1. Docker MCP Server 🐳#

类别: 容器化 协议: MCP

Docker 是容器化的事实标准。Agent 掌握 Docker,就能构建、运行、管理容器化应用。

能力说明:

  • 构建 Docker 镜像(docker build)
  • 运行和管理容器(docker run / ps / stop / rm)
  • 镜像仓库操作(push / pull)
  • Docker Compose 编排
  • 日志查看和调试

Agent 使用场景:

# Agent 生成的多阶段构建 Dockerfile
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
FROM node:20-alpine AS runner
WORKDIR /app
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 appuser
COPY --from=builder --chown=appuser:nodejs /app/dist ./dist
COPY --from=builder --chown=appuser:nodejs /app/node_modules ./node_modules
USER appuser
EXPOSE 3000
CMD ["node", "dist/main.js"]
Terminal window
# Agent 管理容器
docker build -t myapp:latest .
docker run -d -p 3000:3000 --name myapp myapp:latest
docker logs -f myapp
docker stats myapp

典型指令:

为这个 Node.js 项目编写 Dockerfile 和 docker-compose.yml,
包含应用、PostgreSQL 和 Redis 三个服务,
配置健康检查和自动重启。

2. Kubernetes MCP Server ☸️#

类别: 容器编排 协议: MCP

Kubernetes 是生产级容器编排的标准。Agent 掌握 K8s,就能管理大规模应用的部署、扩缩容、自愈。

能力说明:

  • 部署管理(Deployment / StatefulSet / DaemonSet)
  • 服务发现(Service / Ingress)
  • 配置管理(ConfigMap / Secret)
  • 自动扩缩容(HPA)
  • 故障排查(Events / Logs / Describe)

Agent 使用场景:

# Agent 生成的 K8s 部署配置
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
labels:
app: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: myapp:latest
ports:
- containerPort: 3000
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 3000
initialDelaySeconds: 5
periodSeconds: 5
Terminal window
# Agent 排查集群问题
kubectl get pods -A | grep -v Running
kubectl describe pod <failing-pod>
kubectl logs <failing-pod> --tail=100
kubectl top pods --sort-by=memory

典型指令:

检查生产集群中所有非 Running 状态的 Pod,
分析失败原因并给出修复建议。

3. Terraform MCP Server 🏗️#

类别: 基础设施即代码 协议: MCP

Terraform 是 IaC(Infrastructure as Code)的领导者。Agent 用它可以声明式地管理云基础设施。

能力说明:

  • 编写 HCL 配置文件
  • 执行 plan / apply / destroy
  • 状态管理
  • 模块化设计
  • 多云支持

Agent 使用场景:

# Agent 生成的 VPC 和 EKS 配置
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "5.0.0"
name = "my-vpc"
cidr = "10.0.0.0/16"
azs = ["us-east-1a", "us-east-1b", "us-east-1c"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]
enable_nat_gateway = true
single_nat_gateway = true
tags = {
Environment = "production"
ManagedBy = "terraform"
}
}
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "19.0.0"
cluster_name = "my-cluster"
cluster_version = "1.28"
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets
eks_managed_node_groups = {
general = {
desired_size = 3
min_size = 2
max_size = 10
instance_types = ["t3.medium"]
}
}
}

典型指令:

用 Terraform 在 AWS 上搭建一个 EKS 集群,
包含 VPC、子网、NAT 网关、安全组,
要求支持多可用区和自动扩缩容。

4. AWS CLI / SDK ☁️#

类别: 云服务 适用工具: AWS CLI / Boto3

AWS 是全球最大的云平台。Agent 掌握 AWS CLI/SDK,就能管理 EC2、S3、Lambda、RDS 等数百种服务。

能力说明:

  • EC2 实例管理
  • S3 存储操作
  • Lambda 函数部署
  • RDS 数据库管理
  • IAM 权限管理
  • CloudWatch 监控

Agent 使用场景:

Terminal window
# Agent 管理 S3 存储
aws s3 ls s3://my-bucket/ --recursive --human-readable
aws s3 cp ./dist/ s3://my-bucket/releases/v1.0/ --recursive
aws s3 sync ./data/ s3://my-bucket/data/ --delete
# Agent 查看 EC2 实例状态
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,State.Name,InstanceType]' --output table
# Agent 部署 Lambda
aws lambda update-function-code \
--function-name my-function \
--zip-file fileb://function.zip
# Agent 用 Boto3 自动化运维
import boto3
def cleanup_old_snapshots(days=30):
ec2 = boto3.client('ec2')
cutoff = datetime.now() - timedelta(days=days)
snapshots = ec2.describe_snapshots(OwnerIds=['self'])
for snap in snapshots['Snapshots']:
if snap['StartTime'].replace(tzinfo=None) < cutoff:
ec2.delete_snapshot(SnapshotId=snap['SnapshotId'])
print(f"Deleted snapshot: {snap['SnapshotId']}")

典型指令:

检查 AWS 账号中所有未绑定的 EIP 和未挂载的 EBS 卷,
这些是浪费成本的闲置资源,列出它们并计算每月浪费的费用。

5. CI/CD Pipeline 🔄#

类别: 持续集成/持续部署 适用工具: GitHub Actions / GitLab CI / CircleCI

CI/CD 是现代开发的基础设施。Agent 可以编写和优化 CI/CD 流水线,实现代码从提交到上线的全自动化。

能力说明:

  • 流水线配置编写
  • 构建、测试、部署自动化
  • 缓存优化
  • 矩阵构建
  • 环境管理

Agent 使用场景:

# Agent 生成的 GitHub Actions 工作流
name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm run lint
- run: pnpm run type-check
- run: pnpm run test --coverage
- uses: codecov/codecov-action@v3
deploy:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
- name: Deploy to production
run: |
docker build -t myapp:${{ github.sha }} .
docker push myregistry/myapp:${{ github.sha }}
kubectl set image deployment/myapp myapp=myregistry/myapp:${{ github.sha }}

典型指令:

为这个项目编写 GitHub Actions 工作流,
包含 lint、test、build、deploy 四个阶段,
main 分支部署到生产环境,其他分支部署到预览环境。

6. 日志收集与分析 📋#

类别: 可观测性 适用工具: ELK Stack / Loki / CloudWatch Logs

日志是排查问题的第一手资料。Agent 可以分析日志、发现异常、生成报告。

能力说明:

  • 日志查询和过滤
  • 错误模式识别
  • 日志聚合分析
  • 告警规则配置

Agent 使用场景:

Terminal window
# Agent 分析 Nginx 访问日志
# 找出最近 1 小时的 5xx 错误
awk '$9 >= 500 && $9 < 600 {print $0}' /var/log/nginx/access.log | tail -50
# 统计每个 IP 的请求数,找出异常高频 IP
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -20
# 分析慢请求
awk '$NF > 5 {print $7, $NF"s"}' /var/log/nginx/access.log | sort -t' ' -k2 -rn | head -20
# Agent 用 Python 分析应用日志
import re
from collections import Counter
def analyze_logs(log_file):
error_pattern = re.compile(r'ERROR.*?(\w+Error): (.+)')
errors = Counter()
with open(log_file) as f:
for line in f:
match = error_pattern.search(line)
if match:
error_type, message = match.groups()
errors[f"{error_type}: {message[:50]}"] += 1
print("🔥 Top Errors:")
for error, count in errors.most_common(10):
print(f" {count:5d} | {error}")

典型指令:

分析最近 24 小时的应用日志,
找出最频繁的 10 种错误,
统计每种错误的出现次数和影响的用户数。

7. 监控与告警 🚨#

类别: 可观测性 适用工具: Prometheus / Grafana / PagerDuty

监控是系统的”眼睛”,告警是系统的”嘴”。Agent 可以配置监控指标、设置告警规则、分析告警趋势。

能力说明:

  • 指标查询(PromQL)
  • 仪表板管理(Grafana)
  • 告警规则配置
  • 告警分析和降噪

Agent 使用场景:

# Agent 生成的 Prometheus 告警规则
groups:
- name: application
rules:
- alert: HighErrorRate
expr: |
sum(rate(http_requests_total{status=~"5.."}[5m]))
/
sum(rate(http_requests_total[5m]))
> 0.05
for: 5m
labels:
severity: critical
annotations:
summary: "High error rate detected"
description: "Error rate is {{ $value | humanizePercentage }} (threshold: 5%)"
- alert: HighLatency
expr: |
histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m])) > 2
for: 10m
labels:
severity: warning
annotations:
summary: "High P95 latency"
description: "P95 latency is {{ $value }}s (threshold: 2s)"
Terminal window
# Agent 查询 Prometheus 指标
curl -s 'http://prometheus:9090/api/v1/query?query=up' | jq '.data.result[] | {instance: .metric.instance, value: .value[1]}'

典型指令:

检查当前所有活跃的告警,分析是否有误报,
如果有告警风暴(同类型告警超过 10 条),给出降噪建议。

8. Cloudflare MCP Server 🌐#

类别: 边缘计算 协议: MCP

Cloudflare 是全球最大的 CDN 和边缘计算平台,覆盖全球 300+ 城市。通过 MCP Server,Agent 可以直接管理 Cloudflare 的全套服务——从 Workers 部署到 DNS 配置,从安全规则到 KV 存储,一句话搞定边缘侧的一切。

能力说明:

  • Workers 部署与管理(Serverless 边缘函数)
  • DNS 记录管理(A / CNAME / MX / TXT)
  • CDN 配置与缓存规则
  • 安全规则(WAF、防火墙、Rate Limiting)
  • KV 存储(全球分布式键值数据库)

Agent 使用场景:

// Agent 通过 MCP 调用 Cloudflare 能力
// 部署一个 Worker 到边缘节点
await mcp.call("cloudflare", "deploy_worker", {
name: "api-gateway",
script: `
export default {
async fetch(request, env) {
const url = new URL(request.url);
// 从 KV 读取路由配置
const route = await env.ROUTER_KV.get(url.pathname);
if (route) {
return fetch(route + url.pathname + url.search);
}
return new Response("Not Found", { status: 404 });
}
}
`,
bindings: [{ name: "ROUTER_KV", type: "kv_namespace" }]
});
// 配置 DNS 记录
await mcp.call("cloudflare", "dns_create", {
zone: "example.com",
type: "A",
name: "api",
content: "1.2.3.4",
proxied: true
});
// 设置 WAF 安全规则
await mcp.call("cloudflare", "firewall_rule_create", {
zone: "example.com",
expression: '(http.request.uri.path contains "/admin") and not ip.src in {10.0.0.0/8}',
action: "block"
});

典型指令:

帮我在 Cloudflare 上部署一个 Worker 作为 API 网关,
配置路由规则,设置对应的 DNS 记录,
并对 /admin 路径启用 WAF 防护。

9. 代码执行沙箱 🧪#

类别: 代码运行 适用工具: E2B / Daytona / 自定义沙箱

代码执行沙箱让 Agent 能安全地运行代码——在隔离环境中执行 Python、Node.js 等脚本,不会影响宿主系统。这是 Agent 从”建议者”进化为”执行者”的关键能力。

能力说明:

  • Python / Node.js 代码执行
  • 包安装(pip / npm,支持自定义依赖)
  • 文件系统访问(读写临时文件)
  • 超时控制(防止死循环和长时间运行)
  • 环境隔离(每次执行互不干扰)

Agent 使用场景:

// Agent 通过 E2B 沙箱执行数据分析代码
import { Sandbox } from "@e2b/code-interpreter";
const sandbox = await Sandbox.create();
// 安装依赖并执行 Python 脚本
const result = await sandbox.runCode(`
import pandas as pd
import matplotlib.pyplot as plt
# 读取数据
df = pd.read_csv('/tmp/sales.csv')
# 数据分析
monthly = df.groupby('month')['revenue'].sum()
print("月度收入汇总:")
print(monthly.to_string())
# 生成图表
plt.figure(figsize=(10, 6))
monthly.plot(kind='bar', color='#6366f1')
plt.title('Monthly Revenue')
plt.savefig('/tmp/chart.png', dpi=150, bbox_inches='tight')
print("图表已保存")
`);
console.log(result.logs.stdout.join('\n'));
// 读取生成的文件
const chart = await sandbox.files.read('/tmp/chart.png');
await sandbox.kill(); // 用完销毁,不留痕迹
// Agent 用沙箱验证代码片段
const sandbox = await Sandbox.create({ timeoutMs: 30000 });
const testResult = await sandbox.runCode(`
def fibonacci(n):
if n <= 1:
return n
a, b = 0, 1
for _ in range(2, n + 1):
a, b = b, a + b
return b
# 测试
for i in [10, 50, 100]:
print(f"fib({i}) = {fibonacci(i)}")
`);
console.log(testResult.logs.stdout);
await sandbox.kill();

典型指令:

在沙箱中运行这段 Python 代码,帮我处理这份 CSV 数据,
生成可视化图表,然后把结果文件下载回来。

10. 多云管理 🌍#

类别: 云架构 适用工具: Pulumi / Crossplane / 对 Terraform 的多 Provider 使用

多云策略可以避免供应商锁定,但也带来管理复杂性。Agent 可以帮助统一管理多云资源。

能力说明:

  • 跨云资源编排
  • 统一监控和日志
  • 成本对比分析
  • 灾难恢复规划

Agent 使用场景:

// Agent 用 Pulumi 管理多云资源
import * as aws from "@pulumi/aws";
import * as gcp from "@pulumi/gcp";
// AWS 上部署主应用
const appCluster = new aws.ecs.Cluster("app-cluster");
const appService = new aws.ecs.Service("app-service", {
cluster: appCluster.arn,
desiredCount: 3,
taskDefinition: appTaskDef.arn,
});
// GCP 上部署数据分析
const dataCluster = new gcp.container.Cluster("data-cluster", {
initialNodeCount: 3,
nodeConfig: {
machineType: "e2-standard-4",
},
});
// 跨云数据同步
const dataSync = new aws.s3.Bucket("data-sync");
const gcsBucket = new gcp.storage.Bucket("gcs-backup");

典型指令:

设计一个多云架构:主应用在 AWS,数据备份在 GCP,
CDN 用 Cloudflare,监控用 Datadog。
画出架构图并给出 Terraform 配置。

本篇小结#

#Skill类别难度价值
1Docker容器化⭐⭐⭐⭐⭐⭐⭐
2Kubernetes容器编排⭐⭐⭐⭐⭐⭐⭐⭐⭐
3TerraformIaC⭐⭐⭐⭐⭐⭐⭐⭐
4AWS CLI/SDK云服务⭐⭐⭐⭐⭐⭐⭐⭐
5CI/CD Pipeline持续部署⭐⭐⭐⭐⭐⭐⭐
6日志分析可观测性⭐⭐⭐⭐⭐⭐⭐
7监控告警可观测性⭐⭐⭐⭐⭐⭐⭐⭐
8Cloudflare MCP边缘计算⭐⭐⭐⭐⭐⭐
9代码执行沙箱代码运行⭐⭐⭐⭐⭐⭐⭐
10多云管理云架构⭐⭐⭐⭐⭐⭐⭐⭐

核心观点: DevOps Skills 是 Agent 的”交付能力”。一个能写 Dockerfile、配置 K8s、管理 CI/CD 的 Agent,才真正具备从代码到上线的全链路能力。


系列导航#

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或赞助支持!

赞助
100 个 Agent Skills 盘点(五):云服务与 DevOps
https://blog.lraymin.cn/posts/agent-skills-cloud/
作者
Claude
发布于
2026-06-15
许可协议
CC BY-NC-SA 4.0
Profile Image of the Author
Raymin
Code & Input & Output
公告
音乐
封面

音乐

暂未播放

0:00 0:00
暂无歌词
分类
标签
站点统计
文章
14
分类
4
标签
44
总字数
28,713
运行时长
0 天
最后活动
0 天前

文章目录