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

@@ -138,27 +138,27 @@ section.block > .sub{margin:-6px 0 16px;font-size:15.6px;color:var(--muted)}
<div class="grp">
<h4>S0 · 起步:环境与心智(约 6h)</h4>
<p>先看清 K8s 到底替你管什么,再在 Windows 11 + WSL2 与 Linux 上各造一个集群,学会用 kubectl 把集群"看穿"。</p>
<div class="lk">
<a href="00-why.html" class="todo">0 从一次线上事故理解 K8s</a>
<a href="01-env.html" class="todo">1 环境搭建双轨</a>
<a href="02-kubectl.html" class="todo">2 kubectl 与集群解剖</a>
<div class="lk" data-auto="S0">
<a href="00-why.html">0 从一次事故理解 K8s</a>
<a href="01-env.html">1 装第一个集群</a>
<a href="02-kubectl.html">2 kubectl 与集群解剖</a>
</div>
</div>
<div class="grp">
<h4>S1 · 跑起来:单服务最小闭环(约 12h)</h4>
<p>把 shop-api 用 Deployment 跑起来、用 Service 暴露、用 ConfigMap/Secret 配置、用探针和资源限制让它活得像生产。</p>
<div class="lk">
<div class="lk" data-auto="S1">
<a href="03-pod.html" class="todo">3 Pod</a>
<a href="04-deployment.html" class="todo">4 Deployment</a>
<a href="05-service.html" class="todo">5 Service 与 DNS</a>
<a href="06-config.html" class="todo">6 ConfigMap/Secret</a>
<a href="06-config.html" class="todo">6 ConfigMap 与 Secret</a>
<a href="07-probe.html" class="todo">7 探针与资源</a>
</div>
</div>
<div class="grp">
<h4>S2 · 撑得住:状态、入口与多服务(约 10h)</h4>
<p>Postgres 落盘成为 StatefulSet,外部流量经 Gateway API 进来,定时任务用 CronJob,多服务之间用 NetworkPolicy 收口。</p>
<div class="lk">
<div class="lk" data-auto="S2">
<a href="08-storage.html">8 存储与 StatefulSet</a>
<a href="09-ingress.html" class="todo">9 入口与网关</a>
<a href="10-job.html" class="todo">10 Job 与 CronJob</a>
@@ -168,9 +168,9 @@ section.block > .sub{margin:-6px 0 16px;font-size:15.6px;color:var(--muted)}
<div class="grp">
<h4>S3 · 看得见:可观测、发布与排障(约 14h)</h4>
<p>日志可查、指标可告警、发布能灰度能回滚、密钥与镜像可追溯,最后用 6 个注入故障练出诊断树。</p>
<div class="lk">
<div class="lk" data-auto="S3">
<a href="12-logging.html" class="todo">12 日志</a>
<a href="13-metrics.html" class="todo">13 指标与 HPA</a>
<a href="13-metrics.html" class="todo">13 指标与扩缩</a>
<a href="14-release.html" class="todo">14 发布策略</a>
<a href="15-supply.html" class="todo">15 密钥与供应链</a>
<a href="16-debug.html" class="todo">16 故障诊断</a>
@@ -179,10 +179,10 @@ section.block > .sub{margin:-6px 0 16px;font-size:15.6px;color:var(--muted)}
<div class="grp">
<h4>S4 · 上生产:集群、调度、安全、交付(约 18h)</h4>
<p>自己搭 3 控制面 HA 集群,把前面所有清单迁过去;然后调度、RBAC 与准入、GitOps、CI/CD、备份升级。</p>
<div class="lk">
<div class="lk" data-auto="S4">
<a href="17-kubeadm.html" class="todo">17 kubeadm HA</a>
<a href="18-schedule.html" class="todo">18 调度与容量</a>
<a href="19-rbac.html" class="todo">19 RBAC 与准入</a>
<a href="18-schedule.html" class="todo">18 节点与调度</a>
<a href="19-rbac.html" class="todo">19 安全基线</a>
<a href="20-gitops.html" class="todo">20 GitOps</a>
<a href="21-ci.html" class="todo">21 CI/CD</a>
<a href="22-backup.html" class="todo">22 备份与升级</a>
@@ -191,8 +191,8 @@ section.block > .sub{margin:-6px 0 16px;font-size:15.6px;color:var(--muted)}
<div class="grp">
<h4>S5 · 守得住:值班、成本与评审(约 8h)</h4>
<p>演练一次 P1 并写复盘、把 requests 虚高的账降下来、用 PRR 给自己打分并规划下一步。</p>
<div class="lk">
<a href="23-oncall.html" class="todo">23 值班与事故响应</a>
<div class="lk" data-auto="S5">
<a href="23-oncall.html" class="todo">23 值班与响应</a>
<a href="24-cost.html" class="todo">24 成本与容量</a>
<a href="25-prr.html" class="todo">25 生产就绪评审</a>
</div>

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": "生产就绪评审"
}
]
}