Skip to content

feat(k3s): idempotent local bring-up, vendored service overlays, and a smoke test - #17

Open
arnoldcastro5000 wants to merge 1 commit into
Greenstand:mainfrom
arnoldcastro5000:k3s-local-bringup
Open

feat(k3s): idempotent local bring-up, vendored service overlays, and a smoke test#17
arnoldcastro5000 wants to merge 1 commit into
Greenstand:mainfrom
arnoldcastro5000:k3s-local-bringup

Conversation

@arnoldcastro5000

Copy link
Copy Markdown

Summary

This makes the local backend easy and reliable to run on your own machine. The
backend runs in a small local Kubernetes cluster (k3d). After this change, a
fresh clone can bring the whole thing up with three commands and check that it
works:

./k3s/prepare-linux.sh   # or ./k3s/prepare.sh on macOS
./k3s/up.sh
./k3s/smoke.sh

What changed:

  • k3s/up.sh is now safe to run again and again. It only builds an image when
    that image is missing, so a second run takes seconds instead of minutes. It
    can heal a half-broken stack, and it warns you before it fills the disk. Use
    ./k3s/up.sh --rebuild to force a fresh build of one service or all of them.
  • k3s/services/ now holds the local setup for each backend service (the
    "kustomize overlays"): treetracker-api, field-data, admin-api, images-api,
    the bulk-pack transformer, the bulk-pack processor, and the admin panel. The
    passwords in these files are local-only dummy values (for example
    postgres:postgres); there are no real secrets.
  • k3s/smoke.sh is a new test. It runs 17 checks end to end: the cluster is
    healthy, the gateway answers, admin login works, the database has the right
    tables, and a fake tree-capture flows all the way through the pipeline into
    the database.
  • k3s/prepare-linux.sh is a new setup script for Linux users. It does the same
    job as the macOS prepare.sh, including pointing the submodules at the right
    branch.
  • The treetracker-admin-client submodule is bumped to 2.0.0, because the
    local admin-panel image is built from that version.

Testing

Ran the full lifecycle from a cold start (no cluster, images built from source):

./k3s/down.sh     # tear everything down
./k3s/up.sh       # build and start the whole stack (~9 min)
./k3s/smoke.sh    # 17 checks

Result: up.sh finished with all pods running, and smoke.sh reported
17 passed, 0 failed. (Check 8 is a known expected "XFAIL": the old v1
transformer is not deployed, so one processed-flag cannot flip. This is by
design, not a failure.)

A second ./k3s/up.sh right after built nothing and changed nothing, which
confirms it is safe to run repeatedly.

Notes

…smoke test

Harden the local k3d capture->verify backend so a fresh clone can run the whole
stack with prepare-linux.sh (or prepare.sh) -> up.sh -> smoke.sh:

- up.sh: build gate (build or pull only when the image is absent from the node),
  a --rebuild flag that also rolls the Deployment, self-heal of unhealthy or
  stale Deployments, a disk preflight, and idempotent CoreDNS and gateway steps.
- Vendor the local-dev kustomize overlays for the capture-pipeline services
  (treetracker-api, field-data, admin-api, images-api, bulk-pack-transformer-v2,
  bulk-pack-processor) and the admin-client, with plain local Secrets replacing
  the base sealed-secrets. Local-dev credentials only.
- smoke.sh: a 17-check end-to-end test (cluster, gateway, auth, DB schemas, and
  a forged bulk-pack row flowing processor -> transformer-v2 -> field-data).
- prepare-linux.sh: a Linux host bootstrap that mirrors prepare.sh, including the
  submodule-branch switching.
- Bump treetracker-admin-client to 2.0.0, which the vendored Dockerfile builds.

Validated by a full down -> up -> smoke cycle from cold: 17 of 17 (step 8 is an
XFAIL by design, the v1 transformer is not deployed).
@arnoldcastro5000

Copy link
Copy Markdown
Author

@dadiorchen for your review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant