From cf672a0aa058d94d7747f324632867d87296a0a0 Mon Sep 17 00:00:00 2001 From: ximenchuifeng Date: Wed, 15 Jul 2026 00:45:54 +0800 Subject: [PATCH] docs(gitops): plan disabling demo mongodb --- .../plans/2026-07-15-disable-demo-mongodb.md | 322 ++++++++++++++++++ 1 file changed, 322 insertions(+) create mode 100644 docs/superpowers/plans/2026-07-15-disable-demo-mongodb.md diff --git a/docs/superpowers/plans/2026-07-15-disable-demo-mongodb.md b/docs/superpowers/plans/2026-07-15-disable-demo-mongodb.md new file mode 100644 index 0000000..4bf06ab --- /dev/null +++ b/docs/superpowers/plans/2026-07-15-disable-demo-mongodb.md @@ -0,0 +1,322 @@ +# Disable Demo MongoDB Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Exclude MongoDB from future default demo infrastructure renders, publish the GitOps state through both repositories, and remove the current test MongoDB workload and storage from `192.168.1.173`. + +**Architecture:** Remove the MongoDB item from the demo environment's data-driven `sharedDatastores` list without changing the reusable Infra chart. Publish the deploy commit, advance the Hub submodule pointer, then perform a narrowly scoped cleanup of the current MongoDB StatefulSet, Service, PVC, and automatically reclaimed storage. + +**Tech Stack:** Helm 4, Argo CD Application manifests, Kubernetes/k3s, Longhorn, Git submodules, Gitee + +## Global Constraints + +- Target only the demo environment and namespace `mixingx` on `192.168.1.173`. +- Keep `sharedInfra.mongo` connection settings unchanged. +- Keep Redis and RabbitMQ datastore entries and runtime resources unchanged. +- Do not modify the reusable `mixingx-infra` Helm chart. +- Keep Audit disabled at `applications/demo/disabled/audit.yaml`. +- MongoDB PVC contents are test data and do not need to be retained. +- Do not delete the Infra Argo CD Application or any unrelated PV/Longhorn volume. +- Never force-push either repository. + +--- + +### Task 1: Exclude MongoDB from demo Infra rendering + +**Files:** +- Modify: `environments/demo/infra-values.yaml` +- Verify unchanged: `applications/demo/disabled/audit.yaml` +- Verify unchanged: `../mixingx-chart/release-charts/mixingx-infra/templates/shared-infra.yaml` + +**Interfaces:** +- Consumes: `sharedDatastores`, rendered by the Infra chart into one StatefulSet and Service per item +- Produces: Demo Infra Helm output containing Redis and RabbitMQ but no MongoDB + +- [ ] **Step 1: Render the baseline and prove MongoDB is currently included** + +Run from `mixingx-deploy`: + +```bash +helm lint ../mixingx-chart/release-charts/mixingx-infra \ + -f environments/demo/image-version.yaml \ + -f environments/demo/infra-values.yaml + +helm template mixingx-infra ../mixingx-chart/release-charts/mixingx-infra \ + -f environments/demo/image-version.yaml \ + -f environments/demo/infra-values.yaml > /tmp/mixingx-infra-before.yaml + +ruby -e "require 'yaml'; names = YAML.load_stream(File.read('/tmp/mixingx-infra-before.yaml')).compact.map { |d| [d['kind'], d.dig('metadata', 'name')] }; abort 'mongo missing from baseline' unless names.include?(['StatefulSet', 'mongo-statefulset']) && names.include?(['Service', 'mongo-service']); puts 'baseline contains mongo'" +``` + +Expected: Helm lint succeeds and the final command prints `baseline contains mongo`. + +- [ ] **Step 2: Remove only the MongoDB datastore item** + +Edit `environments/demo/infra-values.yaml` so `sharedDatastores` changes from: + +```yaml + - name: redis + image: 192.168.1.119:8888/docker-proxy/library/redis:8.6 + port: 6379 + storage: 2Gi + mountPath: /data + - name: mongo + image: 192.168.1.119:8888/docker-proxy/library/mongo:7.0 + port: 27017 + storage: 5Gi + mountPath: /data/db + - name: messaging +``` + +to: + +```yaml + - name: redis + image: 192.168.1.119:8888/docker-proxy/library/redis:8.6 + port: 6379 + storage: 2Gi + mountPath: /data + - name: messaging +``` + +Do not change the `sharedInfra.mongo` mapping above the list. + +- [ ] **Step 3: Render the result and prove only MongoDB is excluded** + +Run: + +```bash +helm lint ../mixingx-chart/release-charts/mixingx-infra \ + -f environments/demo/image-version.yaml \ + -f environments/demo/infra-values.yaml + +helm template mixingx-infra ../mixingx-chart/release-charts/mixingx-infra \ + -f environments/demo/image-version.yaml \ + -f environments/demo/infra-values.yaml > /tmp/mixingx-infra-after.yaml + +ruby -e "require 'yaml'; names = YAML.load_stream(File.read('/tmp/mixingx-infra-after.yaml')).compact.map { |d| [d['kind'], d.dig('metadata', 'name')] }; abort 'mongo still rendered' if names.any? { |x| ['mongo-statefulset', 'mongo-service'].include?(x[1]) }; %w[redis messaging].each { |n| abort \"#{n} missing\" unless names.include?(['StatefulSet', \"#{n}-statefulset\"]) && names.include?(['Service', \"#{n}-service\"]) }; puts 'mongo excluded; redis and messaging retained'" + +test -f applications/demo/disabled/audit.yaml +git diff --check +git diff -- environments/demo/infra-values.yaml +``` + +Expected: Helm lint succeeds, the Ruby command reports MongoDB excluded with Redis and messaging retained, and the Git diff removes only the five-line MongoDB datastore item. + +- [ ] **Step 4: Commit the deploy values change** + +Run: + +```bash +git add environments/demo/infra-values.yaml +git commit -m "chore(gitops): disable demo mongodb" +``` + +Expected: one commit modifying only `environments/demo/infra-values.yaml`. + +--- + +### Task 2: Publish the deploy repository + +**Files:** +- Publish: `mixingx.deploy` branch `master` + +**Interfaces:** +- Consumes: Task 1 commit plus the approved design and implementation plan commits +- Produces: `origin/master` with MongoDB excluded from demo Infra values + +- [ ] **Step 1: Integrate any newer remote commits without force-pushing** + +Run: + +```bash +git fetch origin master +git status --short --branch +git log --oneline --left-right HEAD...origin/master --max-count=20 +git rebase origin/master +``` + +Expected: rebase succeeds. If it conflicts, stop and inspect the remote changes before resolving anything. + +- [ ] **Step 2: Re-run the post-rebase Helm verification** + +Run: + +```bash +helm lint ../mixingx-chart/release-charts/mixingx-infra \ + -f environments/demo/image-version.yaml \ + -f environments/demo/infra-values.yaml + +helm template mixingx-infra ../mixingx-chart/release-charts/mixingx-infra \ + -f environments/demo/image-version.yaml \ + -f environments/demo/infra-values.yaml > /tmp/mixingx-infra-after-rebase.yaml + +ruby -e "require 'yaml'; names = YAML.load_stream(File.read('/tmp/mixingx-infra-after-rebase.yaml')).compact.map { |d| [d['kind'], d.dig('metadata', 'name')] }; abort 'mongo still rendered' if names.any? { |x| ['mongo-statefulset', 'mongo-service'].include?(x[1]) }; %w[redis messaging].each { |n| abort \"#{n} missing\" unless names.include?(['StatefulSet', \"#{n}-statefulset\"]) && names.include?(['Service', \"#{n}-service\"]) }" + +git diff --check origin/master..HEAD +git status --short --branch +``` + +Expected: validation exits 0 and the branch is only ahead of `origin/master`. + +- [ ] **Step 3: Push and verify the remote deploy branch** + +Run: + +```bash +git push origin master +git fetch origin master +git status --short --branch +git ls-tree -r --name-only origin/master | grep -q '^applications/demo/disabled/audit.yaml$' +``` + +Expected: push succeeds, local `master` matches `origin/master`, and Audit remains disabled. + +--- + +### Task 3: Advance and publish the Hub submodule pointer + +**Files:** +- Modify in parent repository: `mixingx-deploy` gitlink +- Preserve: existing untracked `.zcode/plans/` files + +**Interfaces:** +- Consumes: The pushed `mixingx.deploy` commit from Task 2 +- Produces: Hub `develop/v.1.0.1` pointing at that exact deploy commit + +- [ ] **Step 1: Verify the submodule and fetch the Hub remote** + +Run from the parent `mixingx.hub` directory: + +```bash +git -C mixingx-deploy fetch origin master +git -C mixingx-deploy merge --ff-only origin/master +DEPLOY_COMMIT=$(git -C mixingx-deploy rev-parse HEAD) +git fetch origin develop/v.1.0.1 +git status --short --branch +printf 'DEPLOY_COMMIT=%s\n' "$DEPLOY_COMMIT" +``` + +Expected: the deploy submodule equals its `origin/master`. Existing `.zcode/plans/` entries may remain untracked and must not be staged. + +- [ ] **Step 2: Commit only the submodule pointer** + +Run: + +```bash +git add mixingx-deploy +git diff --cached --check +git diff --cached --submodule=log -- mixingx-deploy +git commit -m "chore(gitops): update deploy submodule" +``` + +Expected: one commit changing only the `mixingx-deploy` gitlink. + +- [ ] **Step 3: Rebase safely if Hub advanced remotely** + +Run: + +```bash +git rebase origin/develop/v.1.0.1 +``` + +Expected: rebase succeeds. If the deploy gitlink conflicts, verify the remote deploy pointer is an ancestor of `$DEPLOY_COMMIT` before staging `mixingx-deploy`; otherwise stop and report the conflict. + +- [ ] **Step 4: Push and verify Hub** + +Run: + +```bash +git push origin develop/v.1.0.1 +git fetch origin develop/v.1.0.1 +git status --short --branch +git ls-tree origin/develop/v.1.0.1 mixingx-deploy +``` + +Expected: local and remote branches match, and the remote gitlink equals `$DEPLOY_COMMIT`. + +--- + +### Task 4: Remove MongoDB and its test-data storage from the current cluster + +**Files:** +- Delete Kubernetes resources only in namespace `mixingx` on `192.168.1.173` + +**Interfaces:** +- Consumes: Published GitOps state from Tasks 2 and 3 +- Produces: No MongoDB workload, Service, PVC, PV, or Longhorn volume; Redis and RabbitMQ remain ready + +- [ ] **Step 1: Connect and inventory the exact resources before deletion** + +Connect: + +```bash +ssh mx@192.168.1.173 +sudo -v +``` + +Then run: + +```bash +sudo k3s kubectl get application -n argocd mixingx-infra -o yaml +sudo k3s kubectl get statefulset,service,pod,pvc -n mixingx | grep -E '(^NAME|mongo|redis|messaging)' +PVC=data-mongo-statefulset-0 +PV=$(sudo k3s kubectl get pvc -n mixingx "$PVC" -o jsonpath='{.spec.volumeName}') +SC=$(sudo k3s kubectl get pvc -n mixingx "$PVC" -o jsonpath='{.spec.storageClassName}') +RECLAIM=$(sudo k3s kubectl get pv "$PV" -o jsonpath='{.spec.persistentVolumeReclaimPolicy}') +printf 'PVC=%s\nPV=%s\nSC=%s\nRECLAIM=%s\n' "$PVC" "$PV" "$SC" "$RECLAIM" +``` + +Expected: exact resources are `mongo-statefulset`, `mongo-service`, `mongo-statefulset-0`, and `data-mongo-statefulset-0`. Record a non-empty PV name. If names differ or the PV is shared, stop before deletion. + +- [ ] **Step 2: Delete only the MongoDB workload and Service** + +Run: + +```bash +sudo k3s kubectl delete statefulset -n mixingx mongo-statefulset --wait=true --timeout=120s +sudo k3s kubectl delete service -n mixingx mongo-service --wait=true --timeout=120s +``` + +Expected: both resources report `deleted`. Do not delete the Infra Application. + +- [ ] **Step 3: Delete the MongoDB test-data PVC** + +Run: + +```bash +sudo k3s kubectl delete pvc -n mixingx data-mongo-statefulset-0 --wait=true --timeout=180s +``` + +Expected: the PVC reports `deleted`. If deletion is stuck, inspect finalizers and stop without removing them. + +- [ ] **Step 4: Verify automatic PV and Longhorn reclamation** + +Run: + +```bash +if sudo k3s kubectl get pv "$PV" >/dev/null 2>&1; then + sudo k3s kubectl wait --for=delete "pv/$PV" --timeout=180s +fi + +if sudo k3s kubectl get volumes.longhorn.io -n longhorn-system "$PV" >/dev/null 2>&1; then + sudo k3s kubectl wait --for=delete -n longhorn-system "volumes.longhorn.io/$PV" --timeout=180s +fi +``` + +Expected: both the PV and Longhorn volume are absent. If either remains after the timeout, stop and report it; do not manually delete unrelated storage objects. + +- [ ] **Step 5: Verify MongoDB stays absent and other Infra services remain healthy** + +Run: + +```bash +test -z "$(sudo k3s kubectl get statefulset,service,pod,pvc -n mixingx -o name | grep mongo || true)" +sudo k3s kubectl wait --for=condition=Ready pod/redis-statefulset-0 -n mixingx --timeout=120s +sudo k3s kubectl wait --for=condition=Ready pod/messaging-statefulset-0 -n mixingx --timeout=120s +sleep 30 +test -z "$(sudo k3s kubectl get statefulset,service,pod,pvc -n mixingx -o name | grep mongo || true)" +sudo k3s kubectl get pod -n mixingx redis-statefulset-0 messaging-statefulset-0 +``` + +Expected: both absence checks pass; Redis and RabbitMQ are Ready before and after the observation window.