Skip to content
7 min readUpdated 8 Nov 2026

Secrets

Secrets have one source of truth, GCP Secret Manager, reached through reaktor-secrets and copied into the runtimes that cannot or should not call GCP directly. Built: the common, JVM and JS stores, the Cloudflare Worker binding store, and the BestBuds server loading its credentials from Secret Manager. Designed but not built: manifests, cache ledgers, and cache-first copying into local development, Cloudflare Workers, k3s and deploys. The secret inventory and environment identifiers are not published.

Context — why this exists#

Without a single source of truth, secrets accumulate across a repository — build files, manifests, env files, worker configs — with no rotation path, so changing one value means hand-editing many files across four runtimes. The requirements are usable security: one place to define a secret, automatic delivery to every runtime, no long-lived key files on disk, and rotation as a single operation — without making local dev or deploys painful.

The system runs on four surfaces that each receive secrets differently today: local dev, Cloudflare Workers, the k3s JVM server (on GCE), and the local CI and deploy runner. This design unifies them behind GCP Secret Manager and operates them through reaktor-secrets and workspace operations.

Goals & principles#

  • One source of truth: GCP Secret Manager. Fits the existing GCP palette — we don't add a platform for a single use case.
  • Cache first: payload reads happen only when the local/k3s/Cloudflare cache is missing, or when provider metadata proves the secret has a newer enabled version.
  • No long-lived keys anywhere: local uses your gcloud login (ADC); k3s uses the VM's metadata service account; deploys use the operator's gcloud login on the Mac or the build worker.
  • Pipeline-as-code: pull / sync / rotate / verify are workspace operations and reaktor CLI commands, identical on a laptop and on the build worker. No GUI, no manual copying.
  • Least privilege: each consumer reads only what it needs; most workers get zero secrets.
  • Don't break running surfaces: the cutover is sequenced so production stays up.

Reaktor Secrets module#

reaktor-secrets is the slow-changing secret boundary. Apps and workers should not know whether a value came from GCP Secret Manager, a Kubernetes Secret, a Cloudflare Worker binding, or a local developer fallback. They should depend on a SecretStore.

Implemented primitivePurposeCurrent use
SecretRefStable GCP resource reference to a secret version, never the value.projects//secrets/bestbuds-google-service-account-json/versions/latest
SecretValue / SecretVersionPayload result and version metadata returned by store reads/writes.Carry provider version names without exposing values in higher-level ledgers.
SecretStoreCommon read/write boundary with getString, requireString, and addVersion.Shared API for JVM, JS, Cloudflare, and tests.
SecretStoreAdapterReaktor adapter base for runtime-specific stores.Used by JVM, JS, and Cloudflare implementations.
Feature.SecretsGlobal feature slot for code that wants the configured store.Lets shared code resolve a store without hard-coding a provider.
InMemorySecretStoreTest/local fake with versioned addVersion behavior.Common tests and lightweight fixtures.
Implemented storeRuntimeAuth path
JvmGcpSecretManagerStoreJVM server, desktop tools, k3s jobs, CI helpersGoogle ADC or explicitly supplied GoogleCredentials.
WebGcpSecretManagerStoreJS tools that already hold a scoped bearer tokenSecretAccessTokenProvider; never service-account JSON in browser/client bundles.
CloudflareSecretStoreCloudflare WorkersReads already-synced Worker secret bindings through CloudflareContext.secretOrNull.
BestBudsGoogleCredentialsBestBuds JVM server Pub/Sub and Manna clientsPrefers Secret Manager, then inline/local/classpath fallbacks, then ADC.

Common API:

val ref = SecretRef.gcp("<gcp-project>", "bestbuds-google-service-account-json")
val credentialsJson = store.requireString(ref)

JVM:

val store = JvmGcpSecretManagerStore(defaultProjectId = "<gcp-project>")
val credentialsJson = store.requireString("bestbuds-google-service-account-json")

Cloudflare Workers:

val store = context.boundSecretStore(defaultProjectId = "<gcp-project>")
val clientSecret = store.requireString("BESTBUDS_WORKER_SERVICE_CLIENT_SECRET")

The next layer keeps the same public boundary but adds higher-order operations:

Next primitivePurposeCommon use
SecretManifestDeclarative set of refs required by a component.reaktorServer, companyos-bestbuds, notification-service
SecretSnapshotNon-secret cache ledger: ref, provider version, etag, target, synced time.Decide whether to skip or refresh a materialized cache.
SecretMaterializerWrites a target cache atomically.Kubernetes Secret, Cloudflare Worker secret, local .dev.vars.
SecretGraphGraph nodes for ownership, consumers, target caches, rotations, and audit.Deploy pane, tests, blast radius, stale-cache warnings.

That split follows the Reaktor API rule: today's provider/store layer is small and usable immediately; manifest → materialize → verify becomes the common deploy path once the CLI functions land.

Architecture#

How secrets reach each runtime. GCP Secret Manager is the one source of truth. Local development pulls stage secrets with a gcloud login into gitignored files; Cloudflare Workers receive secrets pushed at deploy and never call GCP; the JVM server on k3s reads through the VM's service account; CI and deploys use the operator's gcloud login. Code depends on a SecretStore, and the designed cache-first rule reads a payload only when a cache is missing or the version changed.GCP Secret Managerthe one source of truth; names {env}-{domain}-{name}Local developmentgcloud ADC login, then agitignored .env and per-Worker .dev.vars files;stage secrets onlypullCloudflare Workerspushed at deploy into theWorker's encrypted secrets;read with CloudflareSecretStore;Workers never call GCPpush at deployJVM server on k3sJvmGcpSecretManagerStorewith the VM's serviceaccount; Kubernetes Secretsas the cache (designed)readCI and deploysthe operator's gcloud loginon the Mac or the buildworker; no file on diskloginCode depends on a SecretStoreA SecretRef names a secret version, never its value.Stores: JvmGcpSecretManagerStore, WebGcpSecretManagerStore,CloudflareSecretStore, and InMemorySecretStore for tests.Cache-first delivery (designed)Read a payload only when the target cache is missingor the enabled version changed. The ledger keeps theversion, etag and state, and never the value.
Built: the stores and the server loading its credentials from Secret Manager. Designed: manifests, cache ledgers and cache-first copying into every target.

Cloudflare Workers can't reach GCP metadata (they run on Cloudflare), so their secrets are pushed to Cloudflare's encrypted per-worker store at deploy time and read at runtime via the existing requireSecret(name) accessor in reaktor-cloudflare. The database stays on Hyperdrive — its connection string lives in the Hyperdrive config server-side, not as a worker secret.

GCP Secret Manager is the canonical source for almost every Reaktor/BestBuds component:

ComponentUses GCP Secret Manager how?Runtime cache
reaktorServer on k3sSupabase, auth, service-account, Cloudflare tunnel, Pub/Sub refs.Kubernetes Secret + in-process snapshot.
reaktor-authJWT keys, service-account signing material, PAT bootstrap secrets.Server memory cache backed by k3s Secret.
BestBuds workersWorker-specific API tokens and service-auth secrets.Cloudflare Worker Secrets / Secrets Store.
CompanyOSGoogle OAuth client secret, test service auth, portal credential references.Cloudflare Worker secret; portal values stay as references.
CI and deploy toolingCloudflare API token, GitHub package token, deploy credentials.Read at deploy time; no checked-in file.
Local devStage-only secrets for emulators and worker dev.Gitignored .env/.dev.vars with a lockfile snapshot.
Desktop/mobileOnly receives user-local tokens or non-secret refs; no direct prod secret fetch.OS keychain for user tokens.
SurfaceAuth to Secret ManagerNotes
Local devgcloud auth application-default login (user ADC)Devs get stage-* secrets only
Cloudflare syncRuns where an operator's gcloud login is available: the Mac or the build workerWorkers never call GCP; secrets are pushed at deploy
k3s serverGCE VM metadata service account → ADCESO uses this; no key file. Grant the node SA secretAccessor
CI and deploysThe operator's gcloud login, on the Mac or the build workerNo service-account key file

Cache-first delivery model#

Target inventory is small: assume about 50 secrets, usually one enabled version each. GCP Secret Manager remains cheap at this scale; the cache design is about blast-radius control, startup speed, and avoiding secret-value movement, not about saving pennies.

The invariant is strict:

A secret payload is read from GCP only when a target cache is missing, or when GCP metadata shows the enabled version changed.

Cache ledger#

Every materialized target gets a non-secret SecretSnapshot ledger:

{
  "target": "k3s://reaktor/app-server-secrets",
  "ref": "secret://gcp/prod/reaktor/auth-jwt-secret",
  "provider": "gcp-secret-manager",
  "providerVersion": "projects/<gcp-project>/secrets/prod-reaktor-auth-jwt-secret/versions/7",
  "etag": "1678f7...",
  "state": "ENABLED",
  "syncedAt": "2026-06-06T00:00:00Z"
}

The ledger never stores plaintext, ciphertext, or a raw hash that could be used as an offline oracle. It stores only provider metadata and target status.

Refresh algorithm#

  1. Load SecretManifest for the target.
  2. For each SecretRef, check the target cache and local SecretSnapshot.
  3. If the target secret is missing, access the provider payload once and write the cache atomically.
  4. If the target exists, read provider metadata only: latest enabled version name, state, update time, and etag.
  5. If metadata matches the snapshot, do nothing.
  6. If metadata changed, access that exact version payload once, replace the target cache, write the new snapshot, and emit a secret.cache.updated graph event.
  7. If access fails, keep the last known-good target cache and mark the graph node stale rather than deleting the runtime secret.

This makes read volume predictable. With 50 secrets, a normal month is roughly: startup/sync metadata checks plus payload reads only for first materialization and rotations. A full redeploy of every target should not imply 50 GCP payload reads unless the target cache is new.

Rotation signal#

The preferred rotation path is:

reaktor secrets put prod/reaktor/auth-jwt-secret
reaktor secrets refresh --target k3s://reaktor/app-server-secrets
reaktor secrets refresh --target cf://companyos-bestbuds

pushSecretVersion writes the GCP version and emits a Reaktor graph event. The caches refresh from that event. If a human rotates a secret directly in the GCP console, periodic metadata reconcile catches it; payload access still happens only when the version differs.

Planned operations#

Secret operations are planned as workspace operations that run the same way on a laptop and on the build worker:

FunctionPurposeWraps
secretsMetadata(env, manifest)Read provider metadata for refs without reading payloads.gcloud secrets versions list/describe
secretsPull(env)Materialize .env + per-worker .dev.vars only if missing/stale.metadata check, then gcloud secrets versions access only on miss/update
syncWorkerSecrets(name, env)Push a Worker's SM secrets to Cloudflare only if missing/stale.wrangler secret list + wrangler secret bulk --name
syncK3sSecrets(env, namespace, secretName)Refresh Kubernetes Secret cache only if missing/stale.kubectl get secret + GCP metadata/payload access
deployWorker(...) / deployWorkers(...)Deploys become secret-aware: compare metadata, sync if needed, then deploy.extends the existing deploy nodes
pushSecretVersion(name, value, env)Set a new value into SM when you rotate; emits graph event.gcloud secrets versions add
verifySecrets(env)Assert each surface resolves required secrets (presence/version, not values).gcloud + wrangler secret list + kubectl get secret

Rotation is then: rotate the value in the vendor console, push it as a new Secret Manager version, and refresh the caches. Cloudflare and k3s update only the caches whose provider version changed. One-time setup (initial IAM and the External Secrets install) stays a runbook.

  • Auth: identity, tokens, permissions and roles.
  • Deployment: plan and apply, and where deploys run.
  • Cloud pane: the operator's view of the infrastructure.