test(gitops): 在 prune 开启后重新纳管测试对象
lint / terraform (push) Successful in 30s
lint / yaml (pull_request) Successful in 8s
lint / ansible (pull_request) Successful in 2m55s
lint / terraform (pull_request) Successful in 30s
lint / yaml (push) Successful in 8s
lint / ansible (push) Successful in 1m59s

This commit is contained in:
2026-09-09 20:13:53 +00:00
parent 342ba4f114
commit 304e18d219
4 changed files with 21 additions and 4 deletions
+8
View File
@@ -36,6 +36,14 @@ What changed in this homelab, when, and why. Newest first.
| GitOps canary | 加入由 Flux 部署到独立 `gitops-canary` namespace 的 `http-echo` Deployment 和 Service;历史 Contour HTTPRoute 明确排除在 Kustomization 之外,初始保持 `prune: false` | | GitOps canary | 加入由 Flux 部署到独立 `gitops-canary` namespace 的 `http-echo` Deployment 和 Service;历史 Contour HTTPRoute 明确排除在 Kustomization 之外,初始保持 `prune: false` |
| prune 验证 | 为 `http-echo` 加入无业务依赖的 `flux-prune-canary` ConfigMap;先在 `prune: false` 下确认 Flux inventory,后续通过独立 PR 删除并仅为 canary 开启 prune | | prune 验证 | 为 `http-echo` 加入无业务依赖的 `flux-prune-canary` ConfigMap;先在 `prune: false` 下确认 Flux inventory,后续通过独立 PR 删除并仅为 canary 开启 prune |
| prune 验证第二阶段 | 第一阶段已确认 `flux-prune-canary` 带 Flux ownership 标签并进入 `http-echo` inventory;从 Git 删除该测试对象,同时仅为 `http-echo` 开启 `prune: true`,root 继续保持 `prune: false` | | prune 验证第二阶段 | 第一阶段已确认 `flux-prune-canary` 带 Flux ownership 标签并进入 `http-echo` inventory;从 Git 删除该测试对象,同时仅为 `http-echo` 开启 `prune: true`,root 继续保持 `prune: false` |
| prune 验证修正 | 第二阶段证明“同一 revision 开启 prune 并删除旧对象”不会回收该对象:Flux 已从 inventory 移除它,但 live ConfigMap 保留。将 ConfigMap 在已经生效的 `prune: true` 下重新纳管,下一 revision 只做删除 |
### Incident: prune 启用与对象删除放在同一 revision
测试把 `http-echo` 从 `prune: false` 改为 `true` 的同时从 Git 删除测试
ConfigMap。Flux 按新 revision 更新了 inventory,但没有删除按旧设置管理的 live
对象,导致 ConfigMap 成为 inventory 之外的残留。没有业务影响。修正方式是在
`prune: true` 已经生效后先重新纳管对象,再用下一 revision 单独删除。
`Carried forward`: re-verify OpenBao/ESO recovery and remaining Secret inventory; `Carried forward`: re-verify OpenBao/ESO recovery and remaining Secret inventory;
configure an off-site Git mirror; plan the Gitea upgrade beyond 1.25.5; configure an off-site Git mirror; plan the Gitea upgrade beyond 1.25.5;
+6 -4
View File
@@ -7,6 +7,7 @@ Flux 将它部署到独立的 `gitops-canary` namespace。
| --- | --- | | --- | --- |
| `deployment.yaml` | 两个 `hashicorp/http-echo` 副本。 | | `deployment.yaml` | 两个 `hashicorp/http-echo` 副本。 |
| `service.yaml` | 只在集群内可达的 ClusterIP Service。 | | `service.yaml` | 只在集群内可达的 ClusterIP Service。 |
| `prune-canary-configmap.yaml` | 无业务依赖的临时资源,用于验证 Flux 受控删除。 |
| `kustomization.yaml` | Flux 实际构建入口;明确排除历史 HTTPRoute。 | | `kustomization.yaml` | Flux 实际构建入口;明确排除历史 HTTPRoute。 |
| `httproute.yaml` | 保留的历史 Contour 示例,**不在 Kustomization 中,不会部署**。 | | `httproute.yaml` | 保留的历史 Contour 示例,**不在 Kustomization 中,不会部署**。 |
@@ -20,7 +21,8 @@ sudo k3s kubectl -n gitops-canary get deployment,service,pod
``` ```
Deployment 漂移修复已经验证:手动把 replicas 改成 1 后,Flux 能按 Git 恢复为 Deployment 漂移修复已经验证:手动把 replicas 改成 1 后,Flux 能按 Git 恢复为
2。删除验证使用无业务依赖的 `flux-prune-canary` ConfigMap:第一阶段已经在 2。删除验证使用无业务依赖的 `flux-prune-canary` ConfigMap。首次尝试在同一个
`prune: false` 时创建并确认进入 Flux inventory;本阶段从 Git 删除该对象,并仅为 revision 中同时开启 prune 并删除对象,Flux 更新了 inventory 但保留了 live 对象。
`http-echo` Kustomization 开启 `prune: true`。root Kustomization 仍保持 因此先在已经生效的 `prune: true` 下重新纳管 ConfigMap;下一 revision 只删除对象,
`prune: false`,brownfield 资源不会进入此次删除范围。 验证垃圾回收。root Kustomization 始终保持 `prune: false`,brownfield 资源不会
进入此次删除范围。
+1
View File
@@ -2,4 +2,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization kind: Kustomization
resources: resources:
- deployment.yaml - deployment.yaml
- prune-canary-configmap.yaml
- service.yaml - service.yaml
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: flux-prune-canary
data:
purpose: verify-controlled-flux-pruning