From e5a040581ad9d709c976b19bd75a2ff9549d516f Mon Sep 17 00:00:00 2001 From: rohow Date: Wed, 22 Apr 2026 19:06:27 +0800 Subject: [PATCH] feat(infra): update infra-gitops.yaml to set suspend to true for post layer --- .env.sample | 6 +----- flux/README.md | 7 ++----- flux/clusters/base/infra-gitops.yaml | 8 +++----- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.env.sample b/.env.sample index 114babc..5d7d411 100644 --- a/.env.sample +++ b/.env.sample @@ -6,11 +6,7 @@ S3_ACCESS_SECRET_KEY=placeholder DNSPOD_SECRET_ID=placeholder DNSPOD_SECRET_KEY=placeholder -# Infra GitOps Post 阶段开关(参见 flux/README.md) -# 如果开启 需要完善 GITEA_ACTIONS_TOKEN / FLUX_WEB_OIDC_CLIENT_ID / FLUX_WEB_OIDC_CLIENT_SECRET 三个变量 -INFRA_GITOPS_POST_SUSPEND=true - -# Gitea Actions Runner Token(Gitea 启动后在 admin → Runners 生成) +# Gitea Actions Runner Token(Gitea 启动后在 admin → Runners 生成,参见 flux/README.md “部署后手工步骤”) GITEA_ACTIONS_TOKEN=placeholder # Flux Operator Web OIDC 凭据(Gitea 启动后创建 OAuth2 应用获取,Redirect URI: https://cd.dev.cm/oauth2/callback) diff --git a/flux/README.md b/flux/README.md index ce891e1..dab1de7 100644 --- a/flux/README.md +++ b/flux/README.md @@ -48,13 +48,12 @@ Kustomization 间通过 `dependsOn` + `wait: true` 串行等待,避免顺序 ## 部署后手工步骤(infra-gitops-post) -`infra-gitops-post` 通过父级 Kustomization 的 `spec.suspend: ${INFRA_GITOPS_POST_SUSPEND:=true}` -默认暂停,因为它依赖两类只能在 Gitea 启动后获取的凭据: +`infra-gitops-post` 在 base 层硬编码 `spec.suspend: true` 默认暂停,因为它依赖两类只能在 Gitea 启动后获取的凭据: 1. **Flux Operator Web 的 OIDC 客户端** 2. **Gitea Actions Runner Token** -`flux-env` Secret 中设置 `INFRA_GITOPS_POST_SUSPEND=true|false`,从而决定 post 层是否自动放行。 +凭据就绪、`flux-env` Secret 重新注入后,使用 `flux resume kustomization infra-gitops-post -n infra-gitops` 手工放行。 步骤: @@ -71,8 +70,6 @@ Kustomization 间通过 `dependsOn` + `wait: true` 串行等待,避免顺序 FLUX_WEB_OIDC_CLIENT_ID= FLUX_WEB_OIDC_CLIENT_SECRET= GITEA_ACTIONS_TOKEN= - - INFRA_GITOPS_POST_SUSPEND=false ``` 5. 重新注入 `flux-env` Secret 并协调: diff --git a/flux/clusters/base/infra-gitops.yaml b/flux/clusters/base/infra-gitops.yaml index f79dd25..b28627e 100644 --- a/flux/clusters/base/infra-gitops.yaml +++ b/flux/clusters/base/infra-gitops.yaml @@ -24,11 +24,9 @@ metadata: name: infra-gitops-post namespace: infra-gitops spec: - # drone/envsubst 不支持多变量逻辑或,因此聚合判断放在 .env → flux-env Secret 这一步: - # 构建脚本会在 GITEA_ACTIONS_TOKEN / FLUX_WEB_OIDC_CLIENT_ID / FLUX_WEB_OIDC_CLIENT_SECRET - # 任一为空时写入 INFRA_GITOPS_POST_SUSPEND=true,三者全部就绪时写入 false。 - # 未设置该变量时(例如旧的 Secret 还没刷新),保守地保持暂停。 - suspend: ${INFRA_GITOPS_POST_SUSPEND:=true} + # 默认暂停:post 层依赖 Gitea 启动后才能获取的 OIDC / Runner Token 凭据。 + # 凭据就绪并写入 flux-env Secret 后,使用 `flux resume kustomization infra-gitops-post -n infra-gitops` 放行。 + suspend: true interval: 30m timeout: 15m retryInterval: 1m