docs(k01): fix readme
This commit is contained in:
+16
-13
@@ -1,17 +1,17 @@
|
||||
# k01 业务集群
|
||||
|
||||
k01 是 juwan-backend 的 k3s 单节点集群。公网入口由 center 的 Caddy 接管——`/wt/*` 走 UDP 直达 chat-api,其余路径反代到 envoy-gateway NodePort 30080。演示阶段一台机器跑完数据层与全部 Go 服务,之后可以加 k02 / k03 扩展。
|
||||
该目录是 juwan-backend 所有 k3s 节点的初始化配置。公网入口由 center 的 Caddy 接管——`/wt/*` 走 UDP 直达 chat-api,其余路径反代到 envoy-gateway NodePort 30080。
|
||||
|
||||
部署机参考:Vultr Regular / 1 vCPU / 1 GB RAM / 32 GB NVMe。
|
||||
第一台机器按以下步骤初始化为 k3s server;后续加入的 k02、k03 只运行 `install-k3s.sh agent`,其他步骤(k8s Secret、CR、业务 yaml)在 server 上 apply 一次即可。
|
||||
|
||||
## 前置条件
|
||||
|
||||
- Ubuntu 26.04 LTS,root
|
||||
- center 已部署,`registry.juwan.xhttp.zip` 可推可拉
|
||||
- 仓库已复制到 `/root/juwan-backend`
|
||||
- 已从 Gitea 拉取仓库:`git clone https://git.juwan.xhttp.zip/juwan/juwan-backend.git`
|
||||
- `/root/registry-password` 文件存放 zot admin 密码(`chmod 600`)
|
||||
|
||||
## 首次部署
|
||||
## k3s server 初始化
|
||||
|
||||
```bash
|
||||
cd /root/juwan-backend/deploy/k01
|
||||
@@ -58,29 +58,32 @@ chat-api 的 WebTransport 走 UDP 8443 hostPort,center Caddy 的 PR 7669 fork
|
||||
|
||||
## 生成的 Secret
|
||||
|
||||
`secrets.sh` 把 `secrets/` 目录填满随机密码,同时 `kubectl create secret` 到 `juwan` namespace。需要用户自己填的是 `.env` 里的 zot admin 密码、Brevo SMTP key 和 Garage S3 access key。
|
||||
`secrets.sh` 生成随机密码写入 `secrets/` 目录,同时 `kubectl create secret` 到 `juwan` namespace。需要手动填的是 `.env` 里的 zot admin 密码、Brevo SMTP key 和 Garage S3 access key。
|
||||
|
||||
CNPG 每个 Cluster Ready 后自动生成 `<cluster>-app` Secret(username/password/dbname/host/port),业务 pod 的 env 直接从这些 Secret 取值。
|
||||
|
||||
## 加节点
|
||||
|
||||
k01 上取 k3s 的 node-token:
|
||||
新机器上执行:
|
||||
|
||||
```bash
|
||||
cd /root/juwan-backend/deploy/k01
|
||||
bash install-k3s.sh agent
|
||||
```
|
||||
|
||||
`install-k3s.sh agent` 会自动从 server 取 node-token 并加入集群。也可以手动操作:
|
||||
|
||||
```bash
|
||||
cat /var/lib/rancher/k3s/server/node-token
|
||||
```
|
||||
|
||||
k02 加入集群:
|
||||
|
||||
```bash
|
||||
curl -sfL https://get.k3s.io | \
|
||||
K3S_URL=https://140.82.15.92:6443 K3S_TOKEN=<token> \
|
||||
K3S_URL=https://<server-ip>:6443 K3S_TOKEN=<token> \
|
||||
sh -
|
||||
scp root@140.82.15.92:/etc/rancher/k3s/registries.yaml /etc/rancher/k3s/
|
||||
scp root@<server-ip>:/etc/rancher/k3s/registries.yaml /etc/rancher/k3s/
|
||||
systemctl restart k3s-agent
|
||||
```
|
||||
|
||||
pod 调度靠 k3s 自动分配。有状态的想粘在指定 node 上就加 `nodeSelector`。
|
||||
pod 调度由 k3s 自动分配。有状态 pod 如需固定在某台节点上,可加 `nodeSelector`。
|
||||
|
||||
## 日常操作
|
||||
|
||||
|
||||
Reference in New Issue
Block a user