Give the api container the token files only #28

Merged
svc-agent-writer merged 1 commit from feat/secret-split into main 2026-10-31 04:21:12 +00:00

Closes #14 (epic #7, ADR 0004 §7).

What changed

  • Kubernetes base: the prepare init container writes two runtime dirs. It sorts the mailmind-secrets keys by name:
    • *.token goes to api.
    • LITESTREAM_* is skipped, because backup already reads those keys as env.
    • Every other key goes to sync: the IMAP password, KEK ring and S3 keys.
    • Each container mounts its own subPath at /etc/mailmind, so the config paths are the same in both. All files stay 0600.
  • Compose: the secrets now come from two directories. api mounts ./local/secrets/api and sync mounts ./local/secrets/sync. The README quick start and the compose header show the new layout.
  • mailmind check: it prints auth: SKIP read token file absent here when no read token file exists, instead of failing. It still runs in the sync container. A token file that exists but is malformed still fails.
  • Tests (2 new):
    • mailmind api starts through cli.main with only the two token files, while the config names an IMAP secret and blob keys that do not exist.
    • check --offline passes with no token files.

Checks

  • make check: clean; 41 tests pass.
  • I rendered kubectl kustomize deploy/k8s/overlays/example and ran the rendered init script against a fake Secret with all eight keys. api got read.token and write.token. sync got imap.secret, kek.json, s3.access and s3.secret. No LITESTREAM_* file landed anywhere, and every file is 0600.

Upgrade notes

  • Compose users must move their files. Tokens go to local/secrets/api/, and everything else goes to local/secrets/sync/.
  • Kubernetes: a token key must end in .token, or api will not see it. The starbase Secrets use read.token, so nothing changes there.
  • Merging next to #27: this PR and #27 both edit the api container in deploy/k8s/base/deployment.yaml, in nearby lines. Whichever merges second may need a rebase.

🤖 Generated with Claude Code

Closes #14 (epic #7, ADR 0004 §7). ## What changed - **Kubernetes base:** the `prepare` init container writes two runtime dirs. It sorts the `mailmind-secrets` keys by name: - `*.token` goes to `api`. - `LITESTREAM_*` is skipped, because `backup` already reads those keys as env. - Every other key goes to `sync`: the IMAP password, KEK ring and S3 keys. - Each container mounts its own subPath at `/etc/mailmind`, so the config paths are the same in both. All files stay `0600`. - **Compose:** the secrets now come from two directories. `api` mounts `./local/secrets/api` and `sync` mounts `./local/secrets/sync`. The README quick start and the compose header show the new layout. - **`mailmind check`:** it prints `auth: SKIP read token file absent here` when no read token file exists, instead of failing. It still runs in the `sync` container. A token file that exists but is malformed still fails. - **Tests (2 new):** - `mailmind api` starts through `cli.main` with only the two token files, while the config names an IMAP secret and blob keys that do not exist. - `check --offline` passes with no token files. ## Checks - `make check`: clean; 41 tests pass. - I rendered `kubectl kustomize deploy/k8s/overlays/example` and ran the rendered init script against a fake Secret with all eight keys. `api` got `read.token` and `write.token`. `sync` got `imap.secret`, `kek.json`, `s3.access` and `s3.secret`. No `LITESTREAM_*` file landed anywhere, and every file is `0600`. ## Upgrade notes - **Compose users** must move their files. Tokens go to `local/secrets/api/`, and everything else goes to `local/secrets/sync/`. - **Kubernetes:** a token key must end in `.token`, or `api` will not see it. The starbase Secrets use `read.token`, so nothing changes there. - **Merging next to #27:** this PR and #27 both edit the `api` container in `deploy/k8s/base/deployment.yaml`, in nearby lines. Whichever merges second may need a rebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The init container now writes one runtime dir per container. api, the
one that faces the network, gets the *.token keys; sync gets the IMAP
password, KEK ring and S3 keys; LITESTREAM_* keys reach backup only, as
env. Compose takes the same split from local/secrets/api and
local/secrets/sync. mailmind check skips the auth line where no token
file exists, so it still runs in the sync container.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No description provided.