fix(kubernetes): 知识地图的章节清单改为 auto 生成,不再残留「待写」

This commit is contained in:
2026-11-08 14:52:18 +08:00
parent 0e37ff54ba
commit 8616ba477c
3 changed files with 265 additions and 46 deletions

View File

@@ -161,6 +161,15 @@ function cards() {
}).join("\n");
}
function stageMap(id) {
return chapters.filter(c => c.stage === id).map(c => {
const label = esc(c.short || c.title.split(":")[0]);
return c.exists
? ` <a href="${c.file}">${c.num} ${label}</a>`
: ` <a href="${c.file}" class="todo">${c.num} ${label}</a>`;
}).join("\n");
}
/* ---------------------------- 3. 写回 ---------------------------- */
const Z = (re, gen, only) => ({ re, gen, only });
@@ -190,6 +199,9 @@ if (fs.existsSync(path.join(root, "index.html"))) {
for (const t of targets) {
const p = path.join(root, t.file);
let html = fs.readFileSync(p, "utf8");
html = html.replace(/<div class="lk" data-auto="(S\d)">[\s\S]*?<\/div>/g,
(m, id) => `<div class="lk" data-auto="${id}">\n${stageMap(id)}\n </div>`);
for (const z of zones) {
if (z.only === "index" && !t.idx) continue;
if (z.only === "chapter" && t.idx) continue;

View File

@@ -1,39 +1,246 @@
{
"_comment": "26 章的唯一清单:章号、文件名、标题、所属阶段、学时。新增或重排章节只改这里,然后跑 node tools/build-nav.js。",
"stages": [
{ "id": "S0", "title": "起步:环境与心智", "hours": "约 6h" },
{ "id": "S1", "title": "跑起来:单服务最小闭环", "hours": "约 12h" },
{ "id": "S2", "title": "撑得住:状态、入口与多服务", "hours": "约 10h" },
{ "id": "S3", "title": "看得见:可观测、发布与排障", "hours": "约 14h" },
{ "id": "S4", "title": "上生产:集群、调度、安全、交付", "hours": "约 18h" },
{ "id": "S5", "title": "守得住:值班、成本与评审", "hours": "约 8h" }
{
"id": "S0",
"title": "起步:环境与心智",
"hours": "约 6h"
},
{
"id": "S1",
"title": "跑起来:单服务最小闭环",
"hours": "约 12h"
},
{
"id": "S2",
"title": "撑得住:状态、入口与多服务",
"hours": "约 10h"
},
{
"id": "S3",
"title": "看得见:可观测、发布与排障",
"hours": "约 14h"
},
{
"id": "S4",
"title": "上生产:集群、调度、安全、交付",
"hours": "约 18h"
},
{
"id": "S5",
"title": "守得住:值班、成本与评审",
"hours": "约 8h"
}
],
"chapters": [
{ "num": 0, "file": "00-why.html", "stage": "S0", "mins": 60, "minBash": 2, "title": "从一次线上事故理解 K8s" },
{ "num": 1, "file": "01-env.html", "stage": "S0", "mins": 150, "title": "环境搭建:Windows 11 + WSL2 与 Linux 双轨" },
{ "num": 2, "file": "02-kubectl.html", "stage": "S0", "mins": 120, "title": "kubectl 与集群解剖" },
{ "num": 3, "file": "03-pod.html", "stage": "S1", "mins": 120, "title": "Pod:最小调度单元" },
{ "num": 4, "file": "04-deployment.html", "stage": "S1", "mins": 150, "title": "Deployment:副本与滚动更新" },
{ "num": 5, "file": "05-service.html", "stage": "S1", "mins": 120, "title": "Service 与集群 DNS" },
{ "num": 6, "file": "06-config.html", "stage": "S1", "mins": 120, "title": "配置与密钥:ConfigMap 与 Secret" },
{ "num": 7, "file": "07-probe.html", "stage": "S1", "mins": 150, "title": "探针与资源:让它活得像生产" },
{ "num": 8, "file": "08-storage.html", "stage": "S2", "mins": 150, "title": "存储:从 emptyDir 到 StatefulSet" },
{ "num": 9, "file": "09-ingress.html", "stage": "S2", "mins": 150, "title": "入口与网关:Ingress 与 Gateway API" },
{ "num": 10, "file": "10-job.html", "stage": "S2", "mins": 90, "title": "Job 与 CronJob:迁移与定时任务" },
{ "num": 11, "file": "11-multisvc.html", "stage": "S2", "mins": 120, "title": "多服务与网络策略" },
{ "num": 12, "file": "12-logging.html", "stage": "S3", "mins": 120, "title": "日志:从 kubectl logs 到可检索" },
{ "num": 13, "file": "13-metrics.html", "stage": "S3", "mins": 150, "title": "指标、扩缩与告警" },
{ "num": 14, "file": "14-release.html", "stage": "S3", "mins": 120, "title": "发布策略:滚动、蓝绿、金丝雀" },
{ "num": 15, "file": "15-supply.html", "stage": "S3", "mins": 120, "title": "密钥与镜像供应链" },
{ "num": 16, "file": "16-debug.html", "stage": "S3", "mins": 180, "title": "故障诊断方法论" },
{ "num": 17, "file": "17-kubeadm.html", "stage": "S4", "mins": 240, "title": "生产集群搭建:kubeadm HA" },
{ "num": 18, "file": "18-schedule.html", "stage": "S4", "mins": 150, "title": "节点、调度与容量" },
{ "num": 19, "file": "19-rbac.html", "stage": "S4", "mins": 180, "title": "安全基线:RBAC 与准入" },
{ "num": 20, "file": "20-gitops.html", "stage": "S4", "mins": 180, "title": "GitOps:Helm/Kustomize + Argo CD" },
{ "num": 21, "file": "21-ci.html", "stage": "S4", "mins": 150, "title": "CI/CD 流水线" },
{ "num": 22, "file": "22-backup.html", "stage": "S4", "mins": 180, "title": "备份、恢复与升级" },
{ "num": 23, "file": "23-oncall.html", "stage": "S5", "mins": 120, "title": "值班与事故响应" },
{ "num": 24, "file": "24-cost.html", "stage": "S5", "mins": 120, "title": "成本与容量" },
{ "num": 25, "file": "25-prr.html", "stage": "S5", "mins": 120, "title": "生产就绪评审与下一步" }
{
"num": 0,
"file": "00-why.html",
"stage": "S0",
"mins": 60,
"minBash": 2,
"title": "从一次线上事故理解 K8s",
"short": "从一次事故理解 K8s"
},
{
"num": 1,
"file": "01-env.html",
"stage": "S0",
"mins": 150,
"title": "环境搭建:Windows 11 + WSL2 与 Linux 双轨",
"short": "装第一个集群"
},
{
"num": 2,
"file": "02-kubectl.html",
"stage": "S0",
"mins": 120,
"title": "kubectl 与集群解剖",
"short": "kubectl 与集群解剖"
},
{
"num": 3,
"file": "03-pod.html",
"stage": "S1",
"mins": 120,
"title": "Pod:最小调度单元",
"short": "Pod"
},
{
"num": 4,
"file": "04-deployment.html",
"stage": "S1",
"mins": 150,
"title": "Deployment:副本与滚动更新",
"short": "Deployment"
},
{
"num": 5,
"file": "05-service.html",
"stage": "S1",
"mins": 120,
"title": "Service 与集群 DNS",
"short": "Service 与 DNS"
},
{
"num": 6,
"file": "06-config.html",
"stage": "S1",
"mins": 120,
"title": "配置与密钥:ConfigMap 与 Secret",
"short": "ConfigMap 与 Secret"
},
{
"num": 7,
"file": "07-probe.html",
"stage": "S1",
"mins": 150,
"title": "探针与资源:让它活得像生产",
"short": "探针与资源"
},
{
"num": 8,
"file": "08-storage.html",
"stage": "S2",
"mins": 150,
"title": "存储:从 emptyDir 到 StatefulSet",
"short": "存储与 StatefulSet"
},
{
"num": 9,
"file": "09-ingress.html",
"stage": "S2",
"mins": 150,
"title": "入口与网关:Ingress 与 Gateway API",
"short": "入口与网关"
},
{
"num": 10,
"file": "10-job.html",
"stage": "S2",
"mins": 90,
"title": "Job 与 CronJob:迁移与定时任务",
"short": "Job 与 CronJob"
},
{
"num": 11,
"file": "11-multisvc.html",
"stage": "S2",
"mins": 120,
"title": "多服务与网络策略",
"short": "多服务与网络策略"
},
{
"num": 12,
"file": "12-logging.html",
"stage": "S3",
"mins": 120,
"title": "日志:从 kubectl logs 到可检索",
"short": "日志"
},
{
"num": 13,
"file": "13-metrics.html",
"stage": "S3",
"mins": 150,
"title": "指标、扩缩与告警",
"short": "指标与扩缩"
},
{
"num": 14,
"file": "14-release.html",
"stage": "S3",
"mins": 120,
"title": "发布策略:滚动、蓝绿、金丝雀",
"short": "发布策略"
},
{
"num": 15,
"file": "15-supply.html",
"stage": "S3",
"mins": 120,
"title": "密钥与镜像供应链",
"short": "密钥与供应链"
},
{
"num": 16,
"file": "16-debug.html",
"stage": "S3",
"mins": 180,
"title": "故障诊断方法论",
"short": "故障诊断"
},
{
"num": 17,
"file": "17-kubeadm.html",
"stage": "S4",
"mins": 240,
"title": "生产集群搭建:kubeadm HA",
"short": "kubeadm HA"
},
{
"num": 18,
"file": "18-schedule.html",
"stage": "S4",
"mins": 150,
"title": "节点、调度与容量",
"short": "节点与调度"
},
{
"num": 19,
"file": "19-rbac.html",
"stage": "S4",
"mins": 180,
"title": "安全基线:RBAC 与准入",
"short": "安全基线"
},
{
"num": 20,
"file": "20-gitops.html",
"stage": "S4",
"mins": 180,
"title": "GitOps:Helm/Kustomize + Argo CD",
"short": "GitOps"
},
{
"num": 21,
"file": "21-ci.html",
"stage": "S4",
"mins": 150,
"title": "CI/CD 流水线",
"short": "CI/CD"
},
{
"num": 22,
"file": "22-backup.html",
"stage": "S4",
"mins": 180,
"title": "备份、恢复与升级",
"short": "备份与升级"
},
{
"num": 23,
"file": "23-oncall.html",
"stage": "S5",
"mins": 120,
"title": "值班与事故响应",
"short": "值班与响应"
},
{
"num": 24,
"file": "24-cost.html",
"stage": "S5",
"mins": 120,
"title": "成本与容量",
"short": "成本与容量"
},
{
"num": 25,
"file": "25-prr.html",
"stage": "S5",
"mins": 120,
"title": "生产就绪评审与下一步",
"short": "生产就绪评审"
}
]
}