ci: 接通 ARM64 镜像发布和预发布部署
This commit is contained in:
parent
1006e8a71e
commit
3f5c2bb137
48
.drone.yml
48
.drone.yml
|
|
@ -23,9 +23,32 @@ steps:
|
|||
- apk add --no-cache openjdk21-jdk maven postgresql-client
|
||||
- mvn -B -ntp -f backend/pom.xml verify
|
||||
- sh deploy/local/ci-smoke.sh
|
||||
trigger:
|
||||
event: [push, pull_request, tag]
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: backend-publish
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
node:
|
||||
atlas-release: "true"
|
||||
|
||||
depends_on:
|
||||
- backend-ci
|
||||
|
||||
steps:
|
||||
- name: package
|
||||
image: maven:3.9.11-eclipse-temurin-21-alpine
|
||||
commands:
|
||||
- mvn -B -ntp -f backend/pom.xml -DskipTests package
|
||||
- name: publish-gateway
|
||||
image: plugins/docker:21.3.8
|
||||
depends_on: [verify]
|
||||
depends_on: [package]
|
||||
settings:
|
||||
registry: git.tutudog.com
|
||||
repo: git.tutudog.com/dongjf/item-atlas-gateway
|
||||
|
|
@ -37,9 +60,6 @@ steps:
|
|||
context: backend/gateway
|
||||
platform: linux/arm64
|
||||
tags: ["${DRONE_COMMIT_SHA}"]
|
||||
when:
|
||||
event: [tag]
|
||||
ref: [refs/tags/v*]
|
||||
- name: publish-inventory-service
|
||||
image: plugins/docker:21.3.8
|
||||
depends_on: [publish-gateway]
|
||||
|
|
@ -54,9 +74,6 @@ steps:
|
|||
context: backend/inventory-service
|
||||
platform: linux/arm64
|
||||
tags: ["${DRONE_COMMIT_SHA}"]
|
||||
when:
|
||||
event: [tag]
|
||||
ref: [refs/tags/v*]
|
||||
- name: publish-intake-service
|
||||
image: plugins/docker:21.3.8
|
||||
depends_on: [publish-inventory-service]
|
||||
|
|
@ -71,17 +88,19 @@ steps:
|
|||
context: backend/intake-service
|
||||
platform: linux/arm64
|
||||
tags: ["${DRONE_COMMIT_SHA}"]
|
||||
when:
|
||||
trigger:
|
||||
event: [tag]
|
||||
ref: [refs/tags/v*]
|
||||
trigger:
|
||||
event: [push, pull_request, tag]
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: deploy-staging
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
node:
|
||||
atlas-deploy: "true"
|
||||
|
||||
|
|
@ -89,6 +108,7 @@ steps:
|
|||
- name: helm-upgrade
|
||||
image: alpine/helm:3.20.0
|
||||
environment:
|
||||
HELM_DRIVER: configmap
|
||||
ATLAS_KUBECONFIG_B64:
|
||||
from_secret: atlas_staging_kubeconfig_b64
|
||||
commands:
|
||||
|
|
@ -97,12 +117,17 @@ steps:
|
|||
trigger:
|
||||
event: [promote]
|
||||
target: [staging]
|
||||
ref: [refs/tags/v*]
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: deploy-production
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
node:
|
||||
atlas-deploy: "true"
|
||||
|
||||
|
|
@ -118,3 +143,6 @@ steps:
|
|||
trigger:
|
||||
event: [promote]
|
||||
target: [production]
|
||||
ref:
|
||||
include: [refs/tags/v*]
|
||||
exclude: [refs/tags/v*-*]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,11 @@ from urllib.parse import urlencode
|
|||
from urllib.request import Request, urlopen
|
||||
|
||||
BASE = os.environ.get("ATLAS_BASE_URL", "http://127.0.0.1:8080").rstrip("/")
|
||||
PASSWORD = os.environ["ATLAS_LOCAL_PASSWORD"]
|
||||
PASSWORD = os.environ.get("ATLAS_LOCAL_PASSWORD")
|
||||
TOKENS = {name: os.environ.get("ATLAS_SMOKE_TOKEN_" + name.upper())
|
||||
for name in ("owner", "viewer", "other")}
|
||||
if not (all(TOKENS.values()) or PASSWORD and not any(TOKENS.values())):
|
||||
raise ValueError("Supply ATLAS_LOCAL_PASSWORD or the three staging access tokens")
|
||||
HOUSE = "/api/households/00000000-0000-0000-0000-000000000001"
|
||||
OTHER_HOUSE = "/api/households/00000000-0000-0000-0000-000000000002"
|
||||
RUN = uuid.uuid4().hex[:8]
|
||||
|
|
@ -22,6 +26,9 @@ def call(method, path, payload=None, *, user="owner", status=200):
|
|||
if data is not None:
|
||||
request.add_header("Content-Type", "application/json")
|
||||
if user:
|
||||
if TOKENS[user]:
|
||||
request.add_header("Authorization", f"Bearer {TOKENS[user]}")
|
||||
else:
|
||||
token = base64.b64encode(f"{user}:{PASSWORD}".encode()).decode()
|
||||
request.add_header("Authorization", f"Basic {token}")
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
## 从提交到部署
|
||||
|
||||
1. Gitea 保存代码。Drone `backend-ci` 在常规提交和发布标签上运行 Java 21、Maven 和 API 冒烟。CI 使用 runner 已缓存的 PostgreSQL 15 镜像做兼容验证,本地和目标部署使用 PostgreSQL 17。发布标签采用 `v*`。标签验证通过后构建并推送三个 ARM64 镜像,镜像标签使用完整提交 SHA。
|
||||
1. Gitea 保存代码。Drone `backend-ci` 在常规提交和发布标签上运行 Java 21、Maven 和 API 冒烟。CI 用 PostgreSQL 15 做兼容验证,本地和部署环境用 PostgreSQL 17。对 `v*` 标签,CI 通过后 ARM64 runner 构建并推送三个镜像。镜像标签使用完整提交 SHA。
|
||||
2. 在 Drone 提升同一个成功构建到 `staging`。部署步骤使用 Helm 3 的 `upgrade --install --atomic --wait`。就绪探针检查应用和数据库,Helm hook 逐个访问 Kubernetes Service。
|
||||
3. 在预发布验证业务请求,再将同一个构建提升到 `production`。正式端口由既有入口配置转发到网关。数据库、Ollama 与 Actuator 保持内部访问。
|
||||
3. 在预发布验证业务请求。正式发布使用同一稳定版本构建与 `production` 提升,带连字符的候选标签只走预发布。正式端口由入口配置转发到网关。数据库、Ollama 与 Actuator 保持内部访问。
|
||||
|
||||
标记 `atlas-deploy=true` 的 Drone runner 须能通过内网访问对应 Kubernetes API。分环境创建 Kubernetes namespace 和作用域受限的发布身份。用 Drone Secrets 提供仓库令牌和对应 namespace 的 kubeconfig。集群内的镜像拉取使用 `item-atlas-registry`。 [Drone Promotion](https://docs.drone.io/user-guide/pipeline/promotion/) · [Helm 升级](https://helm.sh/docs/v3/helm/helm_upgrade/)
|
||||
标记 `atlas-release=true` 的 ARM64 runner 构建镜像。标记 `atlas-deploy=true` 的 runner 须能访问对应 Kubernetes API。分环境创建 namespace 和作用域受限的发布身份。预发布用 ConfigMap 存 Helm 修订,部署账号可维护应用资源。Drone Secrets 保存仓库令牌与分环境的 kubeconfig。集群用 `item-atlas-registry` 拉取镜像。 [Drone Promotion](https://docs.drone.io/user-guide/pipeline/promotion/) · [Helm 升级](https://helm.sh/docs/v3/helm/helm_upgrade/)
|
||||
|
||||
| 位置 | 配置 |
|
||||
| --- | --- |
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
| PostgreSQL | 为两个服务各建一个数据库和登录角色。数据卷在 SSD。首次启动由 Flyway 建表。 |
|
||||
| Ollama | 录入服务设置 `ATLAS_OLLAMA_ENABLED=true` 和内网 `ATLAS_OLLAMA_URL`,模型默认 `gemma4:12b`。 |
|
||||
|
||||
正式数据库使用 `release` 配置,家庭成员按 OIDC `sub` 建立记录。演示数据用单独数据库。首期需要开通家庭时,由管理员在数据库维护窗口建立 `household` 和 `household_member` 对应行。
|
||||
预发布和正式数据库使用 `release` 配置,家庭成员按 OIDC `sub` 建立记录。演示数据用单独数据库。首次开通家庭时,由管理员建立 `household` 和 `household_member` 对应行。预发布冒烟可注入 `ATLAS_SMOKE_TOKEN_OWNER`、`ATLAS_SMOKE_TOKEN_VIEWER`、`ATLAS_SMOKE_TOKEN_OTHER` 三个临时 OIDC 凭据,验证家庭隔离和确认后的后台服务调用。
|
||||
|
||||
## 灰度
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue