Skip to content

Commit 4484da0

Browse files
authored
Merge pull request #26 from podverse/chore/k8s-alignment
chore: update environment variables and documentation
2 parents 6b16b19 + e2ab944 commit 4484da0

245 files changed

Lines changed: 5290 additions & 3567 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cursor/skills/argocd-gitops-push/SKILL.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,36 @@ description: When adding or changing files under infra/k8s/ or sync targets for
99

1010
When adding or changing files under:
1111

12-
- `infra/k8s/` (local, base, or app-of-apps manifests and referenced resources),
13-
- Or any path that is part of an Argo CD Application source (e.g. `infra/k8s/local/apps`, `infra/k8s/local/stack`, `infra/k8s/base/stack`, source under base, and files referenced by those via Kustomize),
14-
- Or **canonical linear migration SQL** under `infra/k8s/base/ops/source/database/linear-migrations/{app,management}/` (versioned chain applied by the linear migration runner),
15-
- Or **ops** manifests under `infra/k8s/base/ops/` (Kustomize bundles: migration CronJob SQL, scripts mounted into jobs, and related `kustomization.yaml` entries that must stay in sync with on-disk files).
12+
- **`infra/k8s/base/`** – reusable Kustomize bases per component (referenced by alpha overlays and/or your GitOps repo),
13+
- **`infra/k8s/alpha/`** – in-repo alpha app-of-apps and child overlays,
14+
- **`infra/k8s/argocd/`** – optional project manifests committed here,
15+
- Any path that is part of an **Argo CD Application** source in **your GitOps repository** (paths vary by installation),
16+
- **Canonical linear migration SQL** under `infra/k8s/base/ops/source/database/linear-migrations/{app,management}/`,
17+
- **Ops** manifests under `infra/k8s/base/ops/` (migration CronJobs, mounted scripts, `kustomization.yaml` entries).
1618

1719
## What Argo CD syncs
1820

19-
- The local app points at repo path `infra/k8s/local/apps` (see `infra/k8s/local-application.yaml`), which references `infra/k8s/local/stack` and the base stack.
20-
- The alpha app-of-apps root points at repo path `infra/k8s/alpha/apps` (see `infra/k8s/alpha-application.yaml`), which references `infra/k8s/alpha/<component>/` overlays.
21-
- Only the **remote** Git repo at the configured revision (e.g. `develop`) is used; the agent does not push. The user must push for Argo CD to see changes.
21+
- **Alpha:** Root **`infra/k8s/alpha-application.yaml`** (when applied) points at **`infra/k8s/alpha/apps`**, which references **`infra/k8s/alpha/<component>/`** overlays.
22+
- **Remote environments:** Application CRs usually live in your **GitOps repo** and reference paths/branches you configure (see [docs/development/k8s/REMOTE-K8S-GITOPS.md](../../../docs/development/k8s/REMOTE-K8S-GITOPS.md)).
23+
- Only the **remote** Git revision Argo CD tracks is authoritative; the agent does not push.
2224

2325
## When a push is required
2426

25-
Any change to files under those paths (or to canonical sources that get copied into them) means the cluster will not reflect the change until the user pushes to the branch Argo CD tracks.
27+
Any change to synced paths (or canonical sources copied into them) is invisible to the cluster until those commits are on the branch Argo CD watches (**often `develop` / `main` on the GitOps repo**).
2628

2729
## Response requirement
2830

29-
When your file-modifying work touches any of these paths, add a short **Push to Git** note in the response (e.g. before or after the verification block):
31+
When file-modifying work touches **`infra/k8s/`** or migration SQL under **`infra/k8s/base/ops/`**, add a short **Push to Git** note:
3032

31-
**Push to Git:** This change affects Argo CD–synced manifests. Push to the branch Argo CD tracks (e.g. `develop`) for the cluster to sync.
33+
**Push to Git:** This change affects Argo CD–synced manifests. Push to the branch Argo CD tracks so the cluster can sync.
3234

3335
## Version updates (GitOps)
3436

35-
- **Manifest changes** (image tags, env, resources, new deployments): Updating the manifest is the change; push is required for Argo CD (covered by the response reminder above).
36-
- **npm/package versions:** Follow the existing AGENTS.md Dependencies section; no separate version rule for GitOps.
37+
- **Manifest changes** (image tags, env, resources): push so Argo CD picks them up.
38+
- **npm/package versions:** Follow AGENTS.md Dependencies; no separate GitOps-only rule.
3739

3840
## See also
3941

40-
- [infra/k8s/INFRA-K8S.md](infra/k8s/INFRA-K8S.md) – k8s layout and local app-of-apps.
41-
- [docs/development/k8s/K3D-ARGOCD-LOCAL.md](docs/development/k8s/K3D-ARGOCD-LOCAL.md) – Local k3d + Argo CD setup.
42+
- [infra/k8s/INFRA-K8S.md](../../../infra/k8s/INFRA-K8S.md) – layout and consumption.
43+
- [docs/development/k8s/REMOTE-K8S-GITOPS.md](../../../docs/development/k8s/REMOTE-K8S-GITOPS.md) – remote cluster workflow.
44+
- [docs/development/k8s/K3D-ARGOCD-LOCAL.md](../../../docs/development/k8s/K3D-ARGOCD-LOCAL.md) – stub (local k3d removed).

.cursor/skills/linear-db-migrations/SKILL.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ version: 1.0.0
99
## When to use
1010

1111
- Adding or changing files under `infra/k8s/base/db/source/`, `infra/k8s/base/ops/`, or `scripts/database/`.
12-
- Wiring DB credentials in Compose, k3d, or K8s manifests, or in env templates/examples.
12+
- Wiring DB credentials in Compose, Kubernetes manifests, or env templates/examples.
1313

1414
## Single source of truth
1515

1616
- **Canonical forward-only SQL:** `infra/k8s/base/ops/source/database/linear-migrations/app/` and `infra/k8s/base/ops/source/database/linear-migrations/management/` (ordered `0001_*.sql`, ...).
17-
- **Bootstrap init (`docker-entrypoint-initdb.d`):** `infra/k8s/base/db/source/bootstrap/` — shell steps **`0001`** / **`0002`**, generated **`0003_linear_baseline.sql.gz`** and **`0004_seed_linear_migration_history.sql`**, then **`0006_management_grants.sh`**.
17+
- **Bootstrap init (`docker-entrypoint-initdb.d`):** `infra/k8s/base/db/source/bootstrap/` — shell steps **`0001`** / **`0002`**, then **`0003_apply_linear_baselines.sh`** with generated **`0003a_app_linear_baseline.sql.gz`** / **`0003b_management_linear_baseline.sql.gz`**.
1818
- **Generated bootstrap artifacts:**
19-
- `infra/k8s/base/db/source/bootstrap/0003_linear_baseline.sql.gz`
20-
- `infra/k8s/base/db/source/bootstrap/0004_seed_linear_migration_history.sql`
19+
- `infra/k8s/base/db/source/bootstrap/0003a_app_linear_baseline.sql.gz`
20+
- `infra/k8s/base/db/source/bootstrap/0003b_management_linear_baseline.sql.gz`
2121
- Generated by scripts under `scripts/database/`; do not hand-edit.
2222

2323
## Runner and validation
2424

2525
- Apply migrations: `bash scripts/database/run-linear-migrations.sh --database app|management` (always pass `--database`; there is no default).
26-
- K8s wrapper: `bash scripts/database/run-linear-migrations-k8s.sh` (same requirement).
26+
- **Credentials:** **app** migrations use `DB_APP_MIGRATOR_USER`, `DB_APP_MIGRATOR_PASSWORD`, `DB_APP_NAME`, `DB_HOST`, and `DB_PORT`. **Management** migrations use `DB_MANAGEMENT_MIGRATOR_USER`, `DB_MANAGEMENT_MIGRATOR_PASSWORD`, `DB_MANAGEMENT_NAME`, `DB_HOST`, and `DB_PORT`. Optional: `infra/config/local/db.env` when keys are unset before sourcing.
27+
- K8s wrapper: `bash scripts/database/run-linear-migrations-k8s.sh` (`--database` required); validates the same keys from Secrets.
2728
- Validate: `bash scripts/database/validate-linear-migrations.sh` (and `--check-db` to compare on-disk checksums to `linear_migration_history` when a DB is available).
2829
- Regenerate baseline artifacts:
2930
- `bash scripts/database/generate-linear-baseline.sh`
30-
- `bash scripts/database/generate-linear-migration-history-seed.sh`
3131
- Verify generated artifacts are committed and up to date:
3232
- `bash scripts/database/verify-linear-baseline.sh`
3333
- The migration runner **creates** the `linear_migration_history` table if missing; do not rely on a dedicated SQL file for that.
@@ -39,13 +39,13 @@ version: 1.0.0
3939

4040
## Environment keys (admin vs image)
4141

42-
- **Authoritative in secrets and generated env:** `DB_APP_ADMIN_USER` / `DB_APP_ADMIN_PASSWORD`, `DB_MANAGEMENT_ADMIN_USER` / `DB_MANAGEMENT_ADMIN_PASSWORD`, plus read-only and read-write keys and `DB_APP_NAME` / `DB_MANAGEMENT_NAME` (see `infra/config/env-templates/db.env.example` and local `infra/config/local/db.env` after `scripts/local-env/setup.sh`).
43-
- The **postgres** container image still reads `POSTGRES_USER` / `POSTGRES_PASSWORD` / `POSTGRES_DB` at runtime—**map** those from the `DB_*_ADMIN_*` and `DB_APP_NAME` keys in Compose or Deployment `env`, not the reverse.
42+
- **Authoritative in secrets and generated env:** owner keys (`DB_APP_OWNER_*`, `DB_MANAGEMENT_OWNER_*`) for bootstrap, migrator keys (`DB_APP_MIGRATOR_*`, `DB_MANAGEMENT_MIGRATOR_*`) for linear migrations, plus read-write and read keys and `DB_APP_NAME` / `DB_MANAGEMENT_NAME` (see `infra/config/env-templates/db.env.example` and local `infra/config/local/db.env` after `scripts/local-env/setup.sh`).
43+
- The **postgres** container image still reads `POSTGRES_USER` / `POSTGRES_PASSWORD` / `POSTGRES_DB` at runtime—**map** those from `DB_APP_OWNER_USER` / `DB_APP_OWNER_PASSWORD` and `DB_APP_NAME` in Compose or Deployment `env`, not the reverse.
4444

4545
## Cross-repo invariants
4646

4747
- Canonical forward-only trees under `infra/k8s/base/ops/source/database/linear-migrations/`.
48-
- Generated bootstrap baseline artifacts `0003` and `0004` are machine-derived and committed.
48+
- Generated bootstrap baseline artifacts `0003a` and `0003b` are machine-derived and committed.
4949
- Same npm script naming model in root `package.json` (`db:migrate:linear:*`, `db:validate:linear`, etc.). Product-specific naming differences are expected.
5050

5151
## Documentation
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: local-docker-env-alignment
3+
description: When adding or changing preconditions, cleanup steps, or env usage for local Docker Compose, keep behavior aligned with shared infra/config/local/*.env and documented teardown flows.
4+
---
5+
6+
# Local Docker Compose env alignment
7+
8+
## When to use
9+
10+
When you:
11+
12+
- Add or change **`make`** targets that touch **`infra/config/local/*.env`** or local containers (`metaboost_local_*`),
13+
- Add guards to **`local_env_clean`** / **`local_clean`**, or
14+
- Document local env setup / teardown.
15+
16+
Metaboost does **not** ship an in-repo local Kubernetes (k3d) path; cluster validation is **remote GitOps**.
17+
18+
## Do
19+
20+
- Keep **`local_env_clean`** blocked while **Docker Compose** Metaboost local containers are running (`make local_down` first).
21+
- Keep **`local_clean`** as full teardown: **`local_down`**, **`local_down_volumes`**, **`test_clean`** (and any other documented test/E2E containers).
22+
- Document that **`make local_env_setup`** and Compose share **`infra/config/local/*.env`** where applicable.
23+
24+
## Don't
25+
26+
- Reference k3d or `make local_k3d_*` (removed).
27+
28+
## Reference targets
29+
30+
- **`local_env_clean`**: Aborts if `metaboost_local_*` containers are running.
31+
- **`local_clean`**: Docker + volumes + test stack teardown.

.cursor/skills/local-docker-k3d-alignment/SKILL.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

.cursor/skills/web/SKILL.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ version: 1.0.0
1212
## Runtime config (sidecar)
1313

1414
- The Next.js app can load runtime config from a sidecar server when `RUNTIME_CONFIG_URL` is set.
15-
- Sidecar runs on a separate port (e.g. 3001) and serves GET `/runtime-config` with env-derived JSON.
15+
- Sidecar runs on a separate port (e.g. 4001) and serves GET `/runtime-config` with env-derived JSON.
1616
- `instrumentation.ts` runs once at server start and fetches config; it is stored in a global/store and used in layout and components.
17+
- Root layout only calls the sidecar when `RUNTIME_CONFIG_URL` is set; on failure it falls back to `getRuntimeConfig()` (`process.env` in dev). Kubernetes bases put `RUNTIME_CONFIG_URL` in `infra/k8s/base/web/source/web.env` (ConfigMap `metaboost-web-config`), not only as a Deployment literal.
1718

1819
## Structure
1920

@@ -26,3 +27,4 @@ version: 1.0.0
2627
- `npm run dev` – Next.js dev server
2728
- `npm run dev:sidecar` – Run sidecar (after building it)
2829
- From root: `npm run dev:web-sidecar` – Build sidecar then run web with sidecar
30+
- `npm run validate-env -w @metaboost/web` (and `-w @metaboost/management-web`) – optional pre-build check that `RUNTIME_CONFIG_URL` is a valid http(s) URL (loads `.env.local` / `.env` like Podverse `validate-env`).

0 commit comments

Comments
 (0)