Skip to main content
Back to blog

如何用 Clanker CLI 操作腾讯云

一篇中文命令行指南,介绍 Clanker CLI 的腾讯云支持,包括凭证、资源清单、多地域扫描、安全检查、TKE kubeconfig、成本命令和 maker 计划。

Clanker CLI 通过 clanker tencent 命令树、clanker ask --tencent 自然语言路径,以及腾讯云 maker 计划支持腾讯云。实现方式是通过腾讯云 SDK 直接调用腾讯云 API,因此不需要额外安装腾讯云 CLI 才能使用这些能力。

配置凭证

先在腾讯云 CAM 中创建符合最小权限原则的凭证。只读查询用只读权限即可;需要执行变更计划时,再授予对应资源的创建、更新或删除权限。

可以使用环境变量:

export TENCENTCLOUD_SECRET_ID="AKID..."
export TENCENTCLOUD_SECRET_KEY="..."
export TENCENTCLOUD_REGION="ap-singapore"

也可以使用 ~/.clanker.yaml:

tencent:
    secret_id: "AKID..."
    secret_key: "..."
    region: ap-singapore

Clanker 也兼容 TENCENT_SECRET_ID、TENCENT_SECRET_KEY 和 TENCENT_REGION。如果没有配置地域,默认使用 ap-singapore。

查询资源清单

需要原始云资源数据时,用直接命令:

clanker tencent list cvm
clanker tencent list vpc --region ap-singapore
clanker tencent list security-groups --all-regions
clanker tencent list tke --format json

命令别名也可以使用:

clanker tc list cvm
clanker tencentcloud regions

当前资源清单覆盖 CVM、VPC、子网、安全组、MySQL/CDB、PostgreSQL、COS、TKE、CLB、EIP、CBS、SSL 证书、CAM 用户、Redis、MongoDB、CynosDB、CDN、EdgeOne、WAF、Anti-DDoS、NAT、VPN、CCN、Direct Connect、Cloud Monitor 告警、CLS 日志主题和 Cloud Audit 跟踪。

用自然语言提问

如果想让 Clanker 先收集腾讯云上下文,再基于真实资源回答,可以使用 --tencent:

clanker ask --tencent "有哪些 CVM 正在运行?"
clanker ask --tencent "哪些安全组把 SSH 暴露到了公网?"
clanker ask --tencent "显示 TKE 集群和节点数量"

上下文收集器默认包含 CVM 清单,并会根据问题里的服务名称补充更多腾讯云服务上下文。

安全、到期、TKE 和成本命令

安全检查:

clanker tencent security public-exposure --region ap-singapore
clanker tencent security db-exposure --region ap-singapore
clanker tencent security cert-expiry --days 14
clanker tencent security all --region ap-singapore

导出 TKE kubeconfig:

clanker tencent kubeconfig cls-abc123 --region ap-singapore > ~/.kube/tencent
KUBECONFIG=~/.kube/tencent kubectl get nodes

到期和续费风险:

clanker tencent expiry
clanker tencent expiry --regions=ap-singapore,ap-jakarta --threshold=14 --format=json
clanker tencent expiry --include-ssl --threshold=30

成本命令:

clanker tencent cost by-product --month 2026-05
clanker tencent cost top --month 2026-05 --limit 20
clanker tencent cost vouchers

注意,账单 API 可能需要和资源清单 API 不同的 CAM 权限。

生成可审阅的腾讯云计划

腾讯云也支持 maker 管道:

clanker ask --maker --tencent "Create a VPC named clanker-demo in ap-singapore"
clanker ask --maker --tencent "Create a security group that allows HTTPS" > plan.json
clanker ask --apply --plan-file plan.json

删除类操作默认被阻止,除非你在生成和执行阶段都显式传入 --destroyer:

clanker ask --maker --destroyer --tencent "Delete the unused test CVM"
clanker ask --apply --destroyer --plan-file plan.json

完整文档:https://docs.clankercloud.ai/cli/cloud/tencent

Put it to work in Workspace

Give your agents a workspace

Bring your project files, choose an Agent, and review saved work in your browser. Create and test reusable Agents when a workflow is ready to repeat.

Try WorkspaceExplore the agent factory