No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
image-updater 62e4291233 build: automatic update of todo-hotfix-make-button-bigger1
updates image todo/todo-web tag '' to 'sha256:f45beeb8240832655b97f4920eb23b8bde3da54c976177583373af91df54bcba'
updates image todo/todo-backend tag '' to 'sha256:adcb845585bda3cf0cf09a9c443e728a082c5b8196efc78ee0e4aceafebf9dbd'
2026-11-05 02:54:20 +00:00
argocd chore(todo-hotfix-make-button-bigger1): web=hotfix-make-button-bigger1(auto=true) backend=dev(auto=true) data=none 2026-11-05 02:51:25 +00:00
base fix(gitops): web Rollout 与 backend 同 sync-wave,否则 backend 暂停会卡住 web 的灰度 2026-11-04 16:40:53 +00:00
envs build: automatic update of todo-hotfix-make-button-bigger1 2026-11-05 02:54:20 +00:00
README.md refactor: 0001_init.sql 移进 base/,不再需要 LoadRestrictionsNone 2026-11-04 22:40:08 +08:00

todo-gitops

todo 案例的环境仓库:应用代码在 todo-web / todo-backend,CI 只产出镜像; 「跑成什么样」全在这里。

todo-gitops/
├── base/                      # 所有环境共用的清单(Deployment/Service/Ingress/db-init Job)
├── base/0001_init.sql         # 表结构唯一事实源(db-init 用它建表,Bytebase 审计看它)
├── envs/<ns>/                 # 一个目录 = 一个环境,由 Tekton pipeline 生成
│   ├── kustomization.yaml     #   namespace + images[].newTag + Ingress host
│   └── restore-job.yaml       #   可选:按日期恢复备份
└── argocd/imageupdaters/      # 可选:开了自动跟踪的环境的 ImageUpdater CR

三个仓怎么串起来

 todo-web / todo-backend  ──push dev/release/v*──►  Forgejo Actions
                                                        │ docker build & push
                                                        ▼
                                              Harbor todo/todo-{web,backend}:<tag>
                                                        │
   Tekton Dashboard 填参数 ──► pipeline todo-env-setup ──┤ 写 envs/<ns>/ + 提交
                                                        ▼
                                              todo-gitops (这个仓)
                                                        │ ApplicationSet 扫 envs/*
                                                        ▼
                                                   Argo CD Application
                                                        │ sync
                                                        ▼
                                    ns <ns>:db-init Job → backend → web → Ingress
                                                        │ 可选:ImageUpdater 跟踪 tag 的 digest
                                                        └─► 自动把新 digest 写回 envs/<ns>/kustomization.yaml

加一个环境

在 Tekton Dashboard 里跑 todo-env-setup,参数:

参数 说明
namespace todo-dev / todo-prod / …(必须是 todo- 前缀)
frontend_image_tag 前端镜像 tag(dev、release-v1.2、v1.2.3…)
allow_frontend_auto_update true = 跟踪这个 tag 的 digest 更新
backend_image_tag / allow_backend_auto_update 同上,后端
data 留空 = 空库;YYYY-MM-DD = 从该日备份恢复一份种子数据

跑完会得到:

  • envs/<ns>/kustomization.yaml 提交进本仓 → 60 秒内 ApplicationSet 生成 Application <ns>
  • 命名空间 <ns>,库 todo_<ns>(共享 Postgres todo-data/todo-db)
  • 域名 https://<ns>.apps.touchall.tech(边缘自动签发证书 + 强制 Casdoor 登录)

删一个环境

删目录、提交。Application 被 ApplicationSet 回收,命名空间和库保留(数据不跟着走)。

注意

  • 不要用手改 envs/<ns>/kustomization.yaml 的 images[].newTag(除非你就是要固定版本): 开了自动跟踪的环境,ImageUpdater 会把自己的写回提交到同一分支,两边一起改会互相打架。
  • 恢复(restore-job.yaml)是一次性对象:Job 名字里带日期,同一天重复跑是 no-op, 换个日期才是新的一次恢复。别在同一命名空间并发跑多个恢复——备份 PVC 是 RWO。
  • 表结构变更请走 Bytebase 工单,不要改完 base/0001_init.sql 就手工 psql。