风险与费用提示
资源影响 读取集群元数据
费用影响 只读查询,不会创建、修改或删除云资源。
输出可能包含集群名称、VPC ID 等环境信息,分享日志前请确认是否需要脱敏。
执行拓扑
Python SDK
TKE API
只读查询
前置条件
- 已准备腾讯云 SecretId 和 SecretKey。
- 账号具有 TKE 查询权限。
- 已复制 cookbook/config.example.yaml 为 cookbook/config.yaml。
参数表
| 参数 | 必填 | 示例 | 说明 |
|---|---|---|---|
--region | 是 | ap-guangzhou | 查询地域。 |
--cluster-id | 否 | cls-xxxxxxxx | 指定集群 ID,可重复传入多个。 |
--cluster-status | 否 | Running | 按集群状态过滤。 |
--cluster-type | 否 | MANAGED_CLUSTER | 按集群类型过滤。 |
--limit | 否 | 100 | 返回数量限制,范围 1 到 100。 |
执行命令
Step 1
cd cookbook Step 2
pip install -r requirements.txt Step 3
python3 cluster/describe_clusters.py --region ap-guangzhou Step 4
python3 cluster/describe_clusters.py --region ap-guangzhou --cluster-id cls-xxxxxxxx 验证步骤
Check 1
确认输出包含集群总数、ClusterId、ClusterName、ClusterStatus 和 RequestId。 Check 2
如传入 --cluster-id,确认返回的集群 ID 与输入一致。 清理步骤
- 该脚本为只读查询,无需清理云资源。
- 如保存了查询日志或导出结果,按团队安全要求脱敏或删除。
Agent Prompt
Prompt
请根据 TKE Workshop 的 describe-clusters Cookbook,查询 ap-guangzhou 下的 TKE 集群列表,并汇总每个集群的名称、ID、状态、版本和节点数。