Skip to content

Scripts

The scripts/ directory holds operator and CI scripts. Most are run by hand when the scenario applies; validate-helm-apps.sh, policy-check.sh and check-image-versions.sh also run in PR CI.

Script Purpose When to run Prerequisites
scripts/ovh/bootstrap-node.sh Harden a fresh Ubuntu server and install k3s (server, extra server or agent) New or replacement server Root (sudo) on the server; Tailscale auth key and/or ADMIN_CIDRS, GHCR read token
scripts/ovh/admin-users.sh Create or lock the sudo logins in ADMIN_USERS, keys from GitHub; turns off root SSH Run by bootstrap-node.sh; re-run when people or keys change Root on the server
scripts/ovh/bootstrap-argocd.sh Install Argo CD once (it then manages itself), seed the two hand-made Secrets, apply the app-of-apps After bootstrap-node.sh kubeconfig for the cluster, gcloud auth, the ESO reader key
scripts/setup-gcp-secrets.sh Set or rotate secret values in GCP Secret Manager First-time setup, rotating credentials, new third-party keys gcloud auth login, project development-485000
scripts/disaster-recovery.sh Restore drill, and Postgres restore from the R2 Barman backups (PITR / latest) with a git cutover Quarterly drill; data corruption, accidental drop, restoring after a lost server kubectl access to the cluster, jq, yq, openssl
scripts/photon-index-local.sh Build a multilingual Photon index from OSM on a large machine and upload it to R2 Photon refresh, or a language-set change Docker + Compose v2, rclone remote r2, the photon-indexer:local image; 32 vCPU / 256 GB RAM / ~1.5 TB NVMe for the planet build
scripts/seed-publish.sh Publish a validated location seed set to r2:tomoda-location-seed/seed/<version>/ After generating a new seed set rclone remote r2
scripts/validate-helm-apps.sh Render every Argo CD Helm Application and validate the output against K8s schemas Before pushing k8s changes (task k8s:validate); runs in k8s-validate.yml helm, yq, kubeconform (via task setup)
scripts/policy-check.sh Render all manifests (raw, Kustomize, Helm apps) and test them against the Rego policies in policy/ with conftest, e.g. every admin Ingress carries the oauth2-proxy middleware Runs in k8s-validate.yml; run locally before changing an Ingress conftest, helm, yq
scripts/check-alert-rules.sh Run promtool check rules on every PrometheusRule in k8s/envs/platform/manifests/ and promtool test rules on k8s/envs/platform/alert-tests/ Runs in k8s-validate.yml; run locally after changing an alert rule promtool, yq
scripts/check-image-versions.sh Fail if a manifest references a devops-built image tag other than its VERSION, or (given a base ref) if an image's build inputs changed without a VERSION bump Runs in images.yml on PRs; run locally before pushing image changes git

disaster-recovery.sh

Flag Does
--drill [--target-time T] [--keep] Restore into a throwaway cluster in restore-drill, compare with prod read-only, report, delete. Never changes prod
--mode latest Restore the latest backup into a new cluster in data (postgres-<env>-<YYYYMMDD> or --name), with the live cluster's TLS SANs, pg_hba, NetworkPolicy and its own backup path. Stops backend writes; needs Argo CD auto-sync paused
--mode pitr --target-time T Same, to a timestamp the WAL archive covers
--mode cutover --name N Edit the working tree so git points the alias Service, CA mirror and alerts at N; no cluster writes
--render DIR Write the drill and recovery manifests rendered from git to DIR, for review or kubeconform

The script never cuts traffic over by itself: the cutover is a reviewed git change. The walkthrough, the drill checks and the cadence are in Disaster Recovery.

photon-index-local.sh

Two-stage pipeline orchestrated by k8s/envs/platform/photon-indexer/docker-compose.build.yml:

  1. mediagis/nominatim imports an OSM extract into a Postgres database. This is the slow stage (hours for regional extracts, days for planet).
  2. photon-indexer:local runs photon -nominatim-import against the warm Nominatim DB to produce the Lucene index.

The script then tarballs the result and uploads it to the R2 bucket tomoda-photon-index (served at photon-index.tomoda.life). Regions are canada, asia, or planet. Defaults assume a 32-vCPU / 256-GB machine with ~1.5 TB NVMe; tune JAVA_HEAP, POSTGRES_SHARED_BUFFERS, POSTGRES_MAINTENANCE_WORK_MEM, and OSM2PGSQL_CACHE downward for laptop builds.

Indexes are built off-cluster only; nothing in the cluster rebuilds them.

setup-gcp-secrets.sh

Upserts against GCP Secret Manager:

  • Env var set and matches the latest version: no-op.
  • Env var set and differs: adds a new version, disables the previous one.
  • Env var unset and the secret has no value: auto-generates for JWT, DB password, Redis password, Backstage master password, the review account password; skips manual secrets (Stripe, Google, Apple, Klipy, DeepSeek, Serper, email).
  • Env var unset and the secret already has a value: preserved.
  • --rotate: regenerates the auto-generated secrets only.

validate-helm-apps.sh

The K8s counterpart to terraform plan: a pre-merge gate for the Helm-based platform. kustomize build | kubeconform (the k8s-validate kustomize job) only sees Kustomize dirs, but most of the platform is Argo CD Applications wrapping Helm charts, which that job never renders. This script walks every application.yaml, resolves each Application's chart + version + values (inline or $values/… multi-source), runs helm template, and validates the output with kubeconform.

Run it before pushing K8s changes:

task k8s:validate

It also runs automatically in the k8s-validate PR workflow (the helm-render job).

What it catches: render failures, structural value mistakes (a value at the wrong nesting level), duplicate keys, and invalid keys only for charts that ship a values.schema.json.

What it does not catch: Helm silently ignores unknown value keys for charts without a schema, and nothing static catches runtime failures (OOM, object-storage credentials, PVC permissions, secret contents). Those surface only once Argo CD syncs and pods run. See Terraform CI/CD for the infra-side equivalent.