Merge branch 'steelhead'

This commit is contained in:
2026-08-06 06:50:38 +08:00
29 changed files with 1320 additions and 354 deletions
+38 -1
View File
@@ -7,9 +7,10 @@
| 文件 | 说明 |
| --- | --- |
| `namespace.yaml` | Namespace:项目专属命名空间 `arcticnewone` |
| `deployment.yaml` | Deployment:SWR 镜像、副本数 1、私有镜像拉取 secrets |
| `deployment.yaml` | Deployment:SWR 镜像、副本数 1、私有镜像拉取 secrets、数据库/SMTP 环境变量 |
| `service.yaml` | Service:ClusterIP,80 端口转发到容器 3000 端口 |
| `ingress.yaml` | Ingress:域名 `personal.virtheart.com`,Traefik + cert-manager 自动签发证书 |
| `postgres.yaml` | (可选)集群内 PostgreSQL StatefulSet + PVC,仅在没有外部数据库时使用 |
`namespace.yaml` 负责创建 `arcticnewone` 命名空间;deployment/service/ingress 三个 YAML 的 `metadata` 均已指定 `namespace: arcticnewone`。
@@ -32,6 +33,24 @@ export SWR_PASSWORD="<密码>"
说明:脚本通过 `--output "type=image,push=true,oci-mediatypes=false"` 一步完成多架构构建推送,使用 Docker V2 manifest 格式(而非 OCI 格式,这是 SWR 兼容的关键),并禁用 provenance/SBOM(`--provenance=false --sbom=false`),保证 SWR 可正常解析。
## 数据库(PostgreSQL)
应用依赖 PostgreSQL 16+ 存储用户、联系留言与订阅数据。两种方式二选一:
### 方式 A:使用云托管数据库(推荐)
使用华为云 RDS for PostgreSQL 等托管服务(自带备份与高可用),创建数据库 `arcticnewone`,连接串格式:
`postgres://<用户>:<密码>@<主机>:<端口>/arcticnewone`
### 方式 B:集群内部署(deploy/postgres.yaml)
```bash
kubectl apply -f deploy/postgres.yaml
```
会创建一个 StatefulSet + PVC(8Gi),数据库地址为 `arcticnewone-postgres.arcticnewone.svc.cluster.local:5432`。
仅建议在测试/低负载场景使用;数据持久化依赖集群存储类。
## 部署前置条件
1. 镜像已构建并推送到华为云 SWR(通过项目根目录 `./build-and-push.sh` 执行,见上方「镜像构建与推送」)
@@ -47,6 +66,22 @@ export SWR_PASSWORD="<密码>"
--dry-run=client -o yaml | kubectl apply -f -
```
5. 创建应用配置 Secret `arcticnewone-secrets`(`database-url` 与 `jwt-secret` 必填;SMTP 项可选,不配置时联系表单/订阅仅入库不发邮件):
```bash
kubectl create secret generic arcticnewone-secrets -n arcticnewone \
--from-literal=database-url='postgres://arcticnewone:<密码>@<数据库地址>:5432/arcticnewone' \
--from-literal=jwt-secret='<随机长字符串,建议 openssl rand -hex 32>' \
--from-literal=postgres-password='<集群内数据库密码,仅方式 B 需要>' \
--from-literal=smtp-host='smtp.example.com' \
--from-literal=smtp-port='465' \
--from-literal=smtp-user='<SMTP 用户名>' \
--from-literal=smtp-pass='<SMTP 密码>' \
--from-literal=smtp-from='北极新一 <noreply@virtheart.com>' \
--from-literal=smtp-contact-to='chenchun@virtheart.com' \
--dry-run=client -o yaml | kubectl apply -f -
```
## 部署步骤
```bash
@@ -57,12 +92,14 @@ kubectl apply -f deploy/ingress.yaml
```
`namespace.yaml` 需最先应用;其余三个 YAML 自带 `namespace: arcticnewone`,`kubectl apply` 时无需额外指定。
若使用集群内数据库,还需先应用 `deploy/postgres.yaml`。
部署后验证:
```bash
kubectl get deploy,svc,ingress -n arcticnewone
kubectl rollout status deployment/arcticnewone -n arcticnewone
kubectl logs deploy/arcticnewone -n arcticnewone | grep '\[db\]' # 确认数据库连接成功
curl -I https://personal.virtheart.com
```