对齐文件规范
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
# 03-07-k3s Longhorn 持久化存储(4 节点实验环境)
|
||||
|
||||
> 本实验:**K3s 四节点集群**、**每节点 8 GiB 内存**(与下文「系统资源」建议档一致)、**磁盘基线为约 10G 系统盘 + 32G 数据盘**,**`/storage`** 必须挂在独立数据盘上(与 `/` 不同设备),详见 `00-04-部署环境说明.md`。**没有 NFS**,用 Longhorn 做集群内动态块存储;若后续要部署 GitLab 等重状态系统,可在此基础上接 PVC。副本数可按实验目标在「省空间」与「模拟高可用」之间取舍。
|
||||
> 本实验:**K3s 四节点集群**、**每节点 8 GiB 内存**(与下文「系统资源」建议档一致)、**磁盘基线为约 10G 系统盘 + 32G 数据盘**,**`/storage`** 必须挂在独立数据盘上(与 `/` 不同设备),详见 `00-02-部署环境说明.md`。**没有 NFS**,用 Longhorn 做集群内动态块存储;若后续要部署 GitLab 等重状态系统,可在此基础上接 PVC。副本数可按实验目标在「省空间」与「模拟高可用」之间取舍。
|
||||
|
||||
|
||||
## TL;DR
|
||||
|
||||
- **自动化验收**:`./scripts/verify.sh run 03-07`
|
||||
- **关键前置**:按本文「前置条件」准备环境变量/Secret/入口 IP
|
||||
- **成功判据**:达到本文「预期」且 playbook 断言通过
|
||||
- **排障**:见本文「排障」
|
||||
|
||||
---
|
||||
|
||||
@@ -8,9 +16,9 @@
|
||||
|
||||
Longhorn 与 K3s 的 `containerd`/镜像、local-path 都会大量占用 **`k3s_data_dir`(本仓库默认 `/storage`)**。若 `/storage` 只是根分区上的普通目录,控制节点易出现 **DiskPressure / Evicted**。
|
||||
|
||||
- **请先阅读**:[`00-04-部署环境说明.md`](00-04-部署环境说明.md)(四节点统一拓扑、自检命令、推荐 playbook 顺序)。
|
||||
- **请先阅读**:[`00-02-部署环境说明.md`](00-02-部署环境说明.md)(四节点统一拓扑、自检命令、推荐 playbook 顺序)。
|
||||
- **自检**(每台节点):`mountpoint -q /storage && findmnt -n -o SOURCE /` 与 `findmnt -n -o SOURCE /storage` 输出须**不同**。
|
||||
- **Ansible**:`k3s-init-and-install.yml` 在 `k3s_verify_storage_mount: true`(`group_vars/all.yml` 默认)时会在安装前校验上述条件;可选先跑 `k3s-prepare-storage.yml` 准备第二块盘,见 `01-06-节点初始化-ansible-实践.md`。
|
||||
- **Ansible**:`01-06.yml -e k3s_do_install=true` 在 `k3s_verify_storage_mount: true`(`group_vars/all.yml` 默认)时会在安装前校验上述条件;可选先跑 `01-06.yml -e k3s_do_prepare_storage=true -e k3s_prepare_storage=true` 准备第二块盘,见 `01-06-节点初始化-ansible-实践.md`。
|
||||
- Longhorn 数据目录建议为 **`/storage/longhorn`**(与 Helm `values-lab.yaml` 一致),勿与系统盘混用。
|
||||
|
||||
**容量与副本数**:每节点数据盘约 **32G** 时,`defaultReplicaCount` 为 **2 或 3** 会使同一份逻辑卷在集群内占用 **多倍物理空间**(各副本落在不同节点上各占一份),且 Longhorn 元数据与系统组件仍有开销;实验环境可先用副本 **1**,要演练跨节点冗余再调高并预留磁盘。
|
||||
@@ -156,10 +164,10 @@ done
|
||||
|
||||
```bash
|
||||
cd ansible
|
||||
ansible-playbook -i inventory.ini playbooks/longhorn-install.yml
|
||||
ansible-playbook -i inventory.ini playbooks/verify/03-07.yml
|
||||
```
|
||||
|
||||
该 playbook 会在各节点安装 iSCSI/NFS 依赖、在控制节点安装 Helm(若 `dnf/yum` 无 `helm` 包则需按 [Helm 安装文档](https://helm.sh/docs/intro/install/)手工安装后重跑)、再 `helm upgrade --install`。values 真源:[`ansible/files/03-07-longhorn/values-lab.yaml`](../ansible/files/03-07-longhorn/values-lab.yaml)。可选:`longhorn_apply_local_path_lab: true` 时一并应用 `03-05` 中的 local-path 实验室 ConfigMap。
|
||||
该 playbook 会在各节点安装 iSCSI/NFS 依赖、在控制节点安装 Helm(若 `dnf/yum` 无 `helm` 包则需按 [Helm 安装文档](https://helm.sh/docs/intro/install/)手工安装后重跑)、再 `helm upgrade --install`。values 真源:[`ansible/files/03-07/values-lab.yaml`](../ansible/files/03-07/values-lab.yaml)。可选:`longhorn_apply_local_path_lab: true` 时一并应用 `03-05` 中的 local-path 实验室 ConfigMap。
|
||||
|
||||
- **手工 Helm**(在 **`ylc61`** 或任意已配置 `KUBECONFIG` 的机器上;kubeconfig 见 `01-01-k3s-控制节点含traefik.md`):
|
||||
|
||||
@@ -169,7 +177,7 @@ export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||
|
||||
helm repo add longhorn https://charts.longhorn.io
|
||||
helm repo update
|
||||
# 将仓库内 ansible/files/03-07-longhorn/values-lab.yaml 拷到本机路径后:
|
||||
# 将仓库内 ansible/files/03-07/values-lab.yaml 拷到本机路径后:
|
||||
helm upgrade --install longhorn longhorn/longhorn \
|
||||
--namespace longhorn-system --create-namespace \
|
||||
-f ./values-lab.yaml \
|
||||
@@ -203,11 +211,11 @@ kubectl -n longhorn-system rollout status deploy/longhorn-ui --timeout=300s
|
||||
|
||||
**不是**在每台机器上各执行一遍安装:无论 **Helm** 还是 **`kubectl apply`**,**对整个集群只做一次**(在能访问 API 的机器上执行即可),Longhorn 的控制面、CSI、DaemonSet 等会由 Kubernetes 统一下发。
|
||||
|
||||
**每台节点**仍要做的是:前文「磁盘前提」「前置条件」里的 **OS 依赖**与 **`/storage/longhorn` 目录**(Ansible `longhorn-install.yml` 会创建)。若节点在集群内且未被 cordon,Longhorn 的 DaemonSet 往往也会在**各节点**拉起组件 Pod,因此各节点通常都要能 **拉取镜像**;只有「存数据」可以只在部分节点上开启(见下文「只让有大盘的节点承载数据」)。
|
||||
**每台节点**仍要做的是:前文「磁盘前提」「前置条件」里的 **OS 依赖**与 **`/storage/longhorn` 目录**(Ansible `03-07.yml` 会创建)。若节点在集群内且未被 cordon,Longhorn 的 DaemonSet 往往也会在**各节点**拉起组件 Pod,因此各节点通常都要能 **拉取镜像**;只有「存数据」可以只在部分节点上开启(见下文「只让有大盘的节点承载数据」)。
|
||||
|
||||
### 首选:Helm + `values-lab.yaml`
|
||||
|
||||
与上文 **「SSH 试跑顺序 §2」**一致:使用 **`ansible-playbook ... longhorn-install.yml`** 或手工 **`helm upgrade --install ... -f values-lab.yaml`**。Chart 仓库:`https://charts.longhorn.io`;values 字段以 [Longhorn Helm Chart](https://github.com/longhorn/longhorn/tree/master/chart) 当前版本为准。
|
||||
与上文 **「SSH 试跑顺序 §2」**一致:使用 **`ansible-playbook ... playbooks/verify/03-07.yml`**(或 `labs/longhorn-stack.yml`)或手工 **`helm upgrade --install ... -f values-lab.yaml`**。Chart 仓库:`https://charts.longhorn.io`;values 字段以 [Longhorn Helm Chart](https://github.com/longhorn/longhorn/tree/master/chart) 当前版本为准。
|
||||
|
||||
### 备选:`kubectl apply` 官方清单
|
||||
|
||||
@@ -496,4 +504,8 @@ Longhorn UI 的部署核对、port-forward、NodePort 与界面内验证要点
|
||||
- `03-05-k3s-local-path-pvc.md`:单副本、无快照需求时,用 K3s 自带 local-path 即可
|
||||
- 返回后续 GitOps / 业务部署(如 GitLab)章节
|
||||
|
||||
## 排障
|
||||
|
||||
- **先看 playbook 输出**:失败时先定位是 deploy/wait/http_check 哪一步。
|
||||
- **集群侧总览**:`kubectl get nodes -o wide`、`kubectl -n kube-system get pods -o wide`。
|
||||
- **事件与日志**:`kubectl -n <ns> describe ...`、`kubectl -n <ns> logs ... --tail=200`。
|
||||
|
||||
Reference in New Issue
Block a user