Skip to content

Commit 72f8a2c

Browse files
author
wenjiehs
committed
docs: reorganize basics node and kubernetes docs
1 parent d429e90 commit 72f8a2c

28 files changed

Lines changed: 1781 additions & 5708 deletions

cookbook/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ python3 supernode/deploy_gpu_pod.py \
135135

136136
| 脚本 | 语言 | 功能 | 文档链接 |
137137
|------|------|------|---------|
138-
| `deploy_nginx.py` | Python | 部署 Nginx 示例 | [docs](../docs/basics/workload/01-create-deployment.md) |
138+
| `deploy_nginx.py` | Python | 部署 Nginx 示例 | [docs](../src/content/docs/basics/kubernetes/02-kubectl-common-operations.md) |
139139

140140
### 超级节点 (supernode/)
141141

cookbook/workload/deploy_nginx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
功能: 在 TKE 集群中部署 Nginx Deployment 和 Service
66
使用方法: python3 deploy_nginx.py --cluster-id cls-xxxxxxxx --replicas 3
7-
文档链接: https://tke-workshop.github.io/basics/workload/01-create-deployment/
7+
文档链接: https://tke-workshop.github.io/basics/kubernetes/02-kubectl-common-operations/
88
"""
99

1010
import argparse

src/content/docs/basics/cluster/01-create-cluster.md

Lines changed: 121 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ title: "如何创建 TKE 集群"
5151
| RunInstancesForNode || Array | 节点创建参数 | 见下方 |
5252
| Region || String | 地域 | ap-guangzhou |
5353

54+
**ClusterBasicSettings 常用参数**:
55+
56+
| 参数名 | 必填 | 类型 | 说明 | 示例值 |
57+
|--------|------|------|------|--------|
58+
| ClusterName || String | 集群名称,建议不超过 50 个字符 | my-tke-cluster |
59+
| ClusterVersion || String | Kubernetes 版本 | 1.28.3 |
60+
| ClusterDescription || String | 集群描述 | 生产集群 |
61+
| VpcId || String | VPC ID | vpc-xxxxxxxx |
62+
| ProjectId || Integer | 项目 ID,默认 0 | 0 |
63+
| TagSpecification || Array | 集群资源标签配置 | 见下方 |
64+
| ClusterLevel || String | 集群规模: L5/L20/L50/L100/L200/L500 | L5 |
65+
| AutoUpgradeClusterLevel || Object | 集群规格自动升配配置 | `{"IsAutoUpgrade": true}` |
66+
5467
**ClusterCIDRSettings 结构**:
5568

5669
```text
@@ -71,13 +84,51 @@ title: "如何创建 TKE 集群"
7184
"ClusterDescription": "测试集群", // 集群描述
7285
"VpcId": "vpc-xxxxxxxx", // VPC ID
7386
"ProjectId": 0, // 项目ID (默认0)
87+
"TagSpecification": [ // 集群资源标签
88+
{
89+
"ResourceType": "cluster",
90+
"Tags": [
91+
{"Key": "env", "Value": "production"},
92+
{"Key": "owner", "Value": "platform-team"}
93+
]
94+
}
95+
],
7496
"ClusterLevel": "L5", // 集群规模: L5/L20/L50/L100/L200/L500
7597
"AutoUpgradeClusterLevel": { // 集群规格自动升配配置
7698
"IsAutoUpgrade": true // 是否自动升配
7799
}
78100
}
79101
```
80102

103+
**TagSpecification 结构**:
104+
105+
```text
106+
[
107+
{
108+
"ResourceType": "cluster", // 标签绑定的资源类型,创建集群时固定为 cluster
109+
"Tags": [
110+
{
111+
"Key": "env", // 标签键
112+
"Value": "production" // 标签值
113+
},
114+
{
115+
"Key": "owner",
116+
"Value": "platform-team"
117+
}
118+
]
119+
}
120+
]
121+
```
122+
123+
常用标签建议:
124+
125+
| 标签键 | 示例值 | 用途 |
126+
|--------|--------|------|
127+
| env | production / staging / test | 区分环境 |
128+
| owner | platform-team | 标识责任团队 |
129+
| cost-center | cc-1001 | 成本分摊 |
130+
| project | payment | 关联业务项目 |
131+
81132
#### Step 2: 调用 CreateCluster API
82133

83134
**使用 cURL (HTTP 直接调用)**:
@@ -103,7 +154,16 @@ curl -X POST "https://tke.tencentcloudapi.com/" \
103154
"ClusterLevel": "L5",
104155
"AutoUpgradeClusterLevel": {
105156
"IsAutoUpgrade": true
106-
}
157+
},
158+
"TagSpecification": [
159+
{
160+
"ResourceType": "cluster",
161+
"Tags": [
162+
{"Key": "env", "Value": "production"},
163+
{"Key": "owner", "Value": "platform-team"}
164+
]
165+
}
166+
]
107167
},
108168
"ClusterCIDRSettings": {
109169
"ClusterCIDR": "172.16.0.0/16",
@@ -130,7 +190,16 @@ tccli tke CreateCluster \
130190
"ClusterLevel": "L5",
131191
"AutoUpgradeClusterLevel": {
132192
"IsAutoUpgrade": true
133-
}
193+
},
194+
"TagSpecification": [
195+
{
196+
"ResourceType": "cluster",
197+
"Tags": [
198+
{"Key": "env", "Value": "production"},
199+
{"Key": "owner", "Value": "platform-team"}
200+
]
201+
}
202+
]
134203
}' \
135204
--ClusterCIDRSettings '{
136205
"ClusterCIDR": "172.16.0.0/16",
@@ -158,6 +227,16 @@ req.ClusterBasicSettings = models.ClusterBasicSettings()
158227
req.ClusterBasicSettings.ClusterName = "my-tke-cluster"
159228
req.ClusterBasicSettings.ClusterVersion = "1.28.3"
160229
req.ClusterBasicSettings.VpcId = "vpc-xxxxxxxx"
230+
tag_spec = models.TagSpecification()
231+
tag_spec.ResourceType = "cluster"
232+
env_tag = models.Tag()
233+
env_tag.Key = "env"
234+
env_tag.Value = "production"
235+
owner_tag = models.Tag()
236+
owner_tag.Key = "owner"
237+
owner_tag.Value = "platform-team"
238+
tag_spec.Tags = [env_tag, owner_tag]
239+
req.ClusterBasicSettings.TagSpecification = [tag_spec]
161240
req.ClusterBasicSettings.ClusterLevel = "L5"
162241
req.ClusterBasicSettings.AutoUpgradeClusterLevel = models.AutoUpgradeClusterLevel()
163242
req.ClusterBasicSettings.AutoUpgradeClusterLevel.IsAutoUpgrade = True
@@ -197,6 +276,15 @@ func main() {
197276
ClusterName: common.StringPtr("my-tke-cluster"),
198277
ClusterVersion: common.StringPtr("1.28.3"),
199278
VpcId: common.StringPtr("vpc-xxxxxxxx"),
279+
TagSpecification: []*tke.TagSpecification{
280+
{
281+
ResourceType: common.StringPtr("cluster"),
282+
Tags: []*tke.Tag{
283+
{Key: common.StringPtr("env"), Value: common.StringPtr("production")},
284+
{Key: common.StringPtr("owner"), Value: common.StringPtr("platform-team")},
285+
},
286+
},
287+
},
200288
ClusterLevel: common.StringPtr("L5"),
201289
AutoUpgradeClusterLevel: &tke.AutoUpgradeClusterLevel{
202290
IsAutoUpgrade: common.BoolPtr(true),
@@ -382,6 +470,31 @@ CoreDNS is running at https://cls-xxxxxxxx.ccs.tencent-cloud.com/api/v1/namespac
382470

383471
`AutoUpgradeClusterLevel` 是对象类型,不是布尔值;当前 CreateCluster API 示例使用 `{"IsAutoUpgrade": true}`
384472

473+
### 配置集群标签
474+
475+
创建集群时可以通过 `ClusterBasicSettings.TagSpecification` 同步绑定标签到集群实例:
476+
477+
```json
478+
{
479+
"ClusterBasicSettings": {
480+
"ClusterName": "prod-payment-gz",
481+
"TagSpecification": [
482+
{
483+
"ResourceType": "cluster",
484+
"Tags": [
485+
{"Key": "env", "Value": "production"},
486+
{"Key": "project", "Value": "payment"},
487+
{"Key": "cost-center", "Value": "cc-1001"}
488+
]
489+
}
490+
]
491+
}
492+
}
493+
```
494+
495+
!!! note "标签说明"
496+
`ResourceType` 创建集群时使用 `cluster`。标签用于资源检索、权限治理和成本分摊,建议在创建时一次性写入基础标签,避免后续补录遗漏。
497+
385498
### 配置集群删除保护
386499

387500
创建后通过 API 启用:
@@ -408,6 +521,7 @@ tccli tke EnableClusterDeletionProtection \
408521
- 容器网络 CIDR: 172.16.0.0/16
409522
- Service CIDR: 10.96.0.0/24
410523
- 集群规模: L5
524+
- 集群标签: env=production, owner=platform-team, cost-center=cc-1001
411525
```
412526

413527
### 带节点创建 Prompt
@@ -437,7 +551,11 @@ tccli tke EnableClusterDeletionProtection \
437551
- L20: 6-20 节点,适合小型生产
438552
- L50: 21-50 节点,适合中型生产
439553
4. **启用删除保护**: 生产集群建议启用删除保护
440-
5. **版本选择**: 选择稳定版本,避免使用最新版本
554+
5. **标签策略**:
555+
- 创建时添加 `env``owner``project``cost-center` 等基础标签
556+
- 标签键和值保持稳定,避免同一含义出现 `team``owner``department` 等多套命名
557+
- 结合 CAM、账单和资源检索需求提前约定标签规范
558+
6. **版本选择**: 选择稳定版本,避免使用最新版本
441559

442560
---
443561

src/content/docs/basics/index.md

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ title: "基础操作"
1111
通过本模块的学习,你将掌握:
1212

1313
- [x] 创建和管理 TKE 集群
14-
- [x] 配置和管理节点与节点池
15-
- [x] 部署和管理工作负载(Deployment)
16-
- [x] 创建和配置服务(Service)
14+
- [x] 配置和管理普通节点、标准节点池、原生节点和超级节点
15+
- [x] 连接集群并使用 kubectl 操作 Kubernetes 对象
1716
- [x] 查看集群和资源的监控信息
1817

1918
## 模块结构
@@ -29,57 +28,78 @@ title: "基础操作"
2928
| [删除集群](cluster/02-delete-cluster.md) | 安全删除集群 | 15 分钟 |
3029
| [查询集群](cluster/04-describe-clusters.md) | 获取集群详细信息 | 15 分钟 |
3130

32-
### 🖥️ 节点管理
33-
管理集群中的工作节点,支持手动添加节点和节点池两种方式
31+
### 🖥️ 普通节点管理
32+
管理集群中的单个 CVM 工作节点,适用于存量 CVM 加入、少量节点调整和节点维护
3433

3534
| 章节 | 内容 | 时间 |
3635
|------|------|------|
3736
| [添加节点](node/01-add-node.md) | 向集群添加节点 | 25 分钟 |
3837
| [删除节点](node/02-delete-node.md) | 从集群移除节点 | 20 分钟 |
38+
| [维护节点](node/03-maintain-node.md) | cordon、drain、uncordon 和排障 | 20 分钟 |
3939
| [查询节点](node/04-describe-nodes.md) | 获取节点详细信息 | 15 分钟 |
4040

41-
### 📦 节点池管理
42-
使用节点池统一管理一组具有相同配置的节点,支持自动伸缩和批量操作
41+
### 📦 标准节点池管理
42+
使用标准节点池统一管理一组普通 CVM 节点,支持自动伸缩、统一标签、污点和批量操作
4343

4444
| 章节 | 内容 | 时间 |
4545
|------|------|------|
4646
| [创建节点池](node-pool/01-create-node-pool.md) | 创建节点池配置 | 30 分钟 |
4747
| [扩缩节点池](node-pool/02-scale-node-pool.md) | 调整节点池规模 | 20 分钟 |
48+
| [查询节点池](node-pool/03-describe-node-pool.md) | 查询节点池列表和详情 | 15 分钟 |
49+
| [删除节点池](node-pool/04-delete-node-pool.md) | 安全删除节点池 | 20 分钟 |
4850

49-
### 🚀 工作负载管理
50-
部署和管理应用工作负载,以 Deployment 为例演示无状态应用的部署
51+
### 🧩 原生节点管理
52+
使用 TKE 原生节点能力,以 `MachineSet` / `Machine` 声明式管理节点,适合高利用率和精细化运维场景
5153

5254
| 章节 | 内容 | 时间 |
5355
|------|------|------|
54-
| [创建 Deployment](workload/01-create-deployment.md) | 部署无状态应用 | 30 分钟 |
55-
| [更新 Deployment](workload/02-update-deployment.md) | 应用滚动更新 | 25 分钟 |
56-
| [删除 Deployment](workload/03-delete-deployment.md) | 清理应用资源 | 15 分钟 |
56+
| [创建原生节点池](native-node/01-create-native-node-pool.md) | 使用 MachineSet 创建原生节点池 | 30 分钟 |
57+
| [扩缩原生节点池](native-node/02-scale-native-node-pool.md) | 调整原生节点池副本和伸缩范围 | 20 分钟 |
58+
| [管理原生节点](native-node/03-manage-native-node.md) | 查询、维护和删除 Machine | 20 分钟 |
5759

58-
### 🌐 服务管理
59-
配置服务(Service)以实现应用的网络访问和负载均衡
60+
### ⚡ 超级节点管理
61+
使用超级节点池承载 Serverless 容器工作负载,适合秒级弹性、按需资源和免节点运维场景
6062

6163
| 章节 | 内容 | 时间 |
6264
|------|------|------|
63-
| [创建 Service](service/01-create-service.md) | 暴露应用服务 | 25 分钟 |
65+
| [创建超级节点池](supernode/01-create-supernode-pool.md) | 创建虚拟节点池 | 25 分钟 |
66+
| [创建按量超级节点](supernode/02-create-supernode.md) | 添加按量虚拟节点 | 20 分钟 |
67+
| [删除超级节点](supernode/03-delete-supernode.md) | 清理虚拟节点资源 | 15 分钟 |
68+
69+
### 🚀 Kubernetes 对象操作
70+
连接 TKE 集群,并使用 `kubectl` 管理 Deployment、Service、ConfigMap、Secret、Ingress、Job 等 Kubernetes 对象。
71+
72+
| 章节 | 内容 | 时间 |
73+
|------|------|------|
74+
| [连接集群](kubernetes/01-connect-cluster.md) | 获取 kubeconfig 并验证 kubectl 访问 | 20 分钟 |
75+
| [常用 kubectl 命令操作](kubernetes/02-kubectl-common-operations.md) | 查看、部署、更新、删除和排障 Kubernetes 对象 | 35 分钟 |
6476

6577
## 学习路径
6678

6779
### 🎯 快速入门路径(新手推荐)
6880

6981
适合首次接触 TKE 的用户,按以下顺序完成基础操作:
7082

71-
1. **创建集群** → 2. **创建节点池** → 3. **创建 Deployment** → 4. **创建 Service**
83+
1. **创建集群** → 2. **创建标准节点池** → 3. **连接集群** → 4. **使用 kubectl 部署对象**
7284

7385
完成时间:约 **2 小时**
7486

7587
### 🏃 进阶实践路径
7688

7789
适合有 Kubernetes 基础的用户,深入了解 TKE 特性:
7890

79-
1. **查询集群详情** → 2. **手动添加节点** → 3. **节点池扩缩容** → 4. **Deployment 更新** → 5. **清理资源**
91+
1. **查询集群详情** → 2. **手动添加节点** → 3. **节点维护** → 4. **节点池扩缩容** → 5. **kubectl 排障** → 6. **清理资源**
8092

8193
完成时间:约 **1.5 小时**
8294

95+
### 🧠 节点能力选型路径
96+
97+
适合需要理解 TKE 节点产品形态的用户:
98+
99+
1. **普通节点管理** → 2. **标准节点池管理** → 3. **原生节点管理** → 4. **超级节点管理**
100+
101+
完成后你将能判断不同工作负载应该使用普通节点池、原生节点还是超级节点。
102+
83103
## 前置准备
84104

85105
开始学习前,请确保已准备:
@@ -126,8 +146,8 @@ title: "基础操作"
126146

127147
本模块的每篇文档都包含:
128148

129-
-**完整的 API 调用示例**可直接复制执行的 JSON 请求
130-
-**CLI 命令参考**tccli 和 kubectl 命令示例
149+
-**云资源 API 示例**集群、节点和节点池使用 tccli/API 示例
150+
-**Kubernetes 对象操作**使用 kubectl 管理集群内对象
131151
-**验证步骤**:确认操作成功的检查方法
132152
-**常见问题排查**:典型错误和解决方案
133153
-**测试报告**:功能测试验证结果
@@ -137,12 +157,13 @@ title: "基础操作"
137157
!!! warning "重要提示"
138158
- 创建集群和节点会产生费用,请关注资源成本
139159
- 删除集群前请备份重要数据
140-
- 生产环境建议使用节点池而非手动管理节点
160+
- 生产环境建议使用标准节点池、原生节点池或超级节点池,而非长期手动管理单个节点
141161
- 所有操作都需要相应的 API 权限
142162

143163
!!! tip "最佳实践"
144164
- 为不同环境(开发/测试/生产)创建独立集群
145165
- 使用节点池标签实现节点分组管理
166+
- 明确区分 Kubernetes 节点标签和腾讯云资源标签
146167
- 为生产应用配置健康检查和资源限制
147168
- 定期检查集群和节点的监控指标
148169

0 commit comments

Comments
 (0)