diff --git a/knowledge/kubernetes/index.html b/knowledge/kubernetes/index.html index 1fefc4f..a1b5725 100644 --- a/knowledge/kubernetes/index.html +++ b/knowledge/kubernetes/index.html @@ -138,27 +138,27 @@ section.block > .sub{margin:-6px 0 16px;font-size:15.6px;color:var(--muted)}

S0 · 起步:环境与心智(约 6h)

先看清 K8s 到底替你管什么,再在 Windows 11 + WSL2 与 Linux 上各造一个集群,学会用 kubectl 把集群"看穿"。

-
- 0 从一次线上事故理解 K8s - 1 环境搭建双轨 - 2 kubectl 与集群解剖 +

S1 · 跑起来:单服务最小闭环(约 12h)

把 shop-api 用 Deployment 跑起来、用 Service 暴露、用 ConfigMap/Secret 配置、用探针和资源限制让它活得像生产。

-

S2 · 撑得住:状态、入口与多服务(约 10h)

Postgres 落盘成为 StatefulSet,外部流量经 Gateway API 进来,定时任务用 CronJob,多服务之间用 NetworkPolicy 收口。

-
+
8 存储与 StatefulSet 9 入口与网关 10 Job 与 CronJob @@ -168,9 +168,9 @@ section.block > .sub{margin:-6px 0 16px;font-size:15.6px;color:var(--muted)}

S3 · 看得见:可观测、发布与排障(约 14h)

日志可查、指标可告警、发布能灰度能回滚、密钥与镜像可追溯,最后用 6 个注入故障练出诊断树。

-
+
12 日志 - 13 指标与 HPA + 13 指标与扩缩 14 发布策略 15 密钥与供应链 16 故障诊断 @@ -179,10 +179,10 @@ section.block > .sub{margin:-6px 0 16px;font-size:15.6px;color:var(--muted)}

S4 · 上生产:集群、调度、安全、交付(约 18h)

自己搭 3 控制面 HA 集群,把前面所有清单迁过去;然后调度、RBAC 与准入、GitOps、CI/CD、备份升级。

-
+
17 kubeadm HA - 18 调度与容量 - 19 RBAC 与准入 + 18 节点与调度 + 19 安全基线 20 GitOps 21 CI/CD 22 备份与升级 @@ -191,8 +191,8 @@ section.block > .sub{margin:-6px 0 16px;font-size:15.6px;color:var(--muted)}

S5 · 守得住:值班、成本与评审(约 8h)

演练一次 P1 并写复盘、把 requests 虚高的账降下来、用 PRR 给自己打分并规划下一步。

-
- 23 值班与事故响应 + diff --git a/knowledge/kubernetes/tools/build-nav.js b/knowledge/kubernetes/tools/build-nav.js index 606c5ad..6a4f731 100644 --- a/knowledge/kubernetes/tools/build-nav.js +++ b/knowledge/kubernetes/tools/build-nav.js @@ -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 + ? ` ${c.num} ${label}` + : ` ${c.num} ${label}`; + }).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(/
[\s\S]*?<\/div>/g, + (m, id) => `
\n${stageMap(id)}\n
`); + for (const z of zones) { if (z.only === "index" && !t.idx) continue; if (z.only === "chapter" && t.idx) continue; diff --git a/knowledge/kubernetes/tools/chapters.json b/knowledge/kubernetes/tools/chapters.json index 8dfa838..6a0c1cc 100644 --- a/knowledge/kubernetes/tools/chapters.json +++ b/knowledge/kubernetes/tools/chapters.json @@ -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": "生产就绪评审" + } ] }