Skip to content

Helm: mount Medic's gateway token Secret; NOTES prints the command that fills it - #4466

Merged
samarmstrong merged 2 commits into
mainfrom
factory/4430-helm-the-gateway-mounts-a-token-c42e8c8a
Nov 16, 2026
Merged

samarmstrong merged 2 commits into
mainfrom
factory/4430-helm-the-gateway-mounts-a-token-c42e8c8a

Conversation

@samarmstrong

Copy link
Copy Markdown
Collaborator

Closes #4430 (part of #4425)

What changed

  • values.yaml: adds medic.gateway.tokenSecret.name (if empty, <release>-medic-gateway-token) and .key (token). viewer.passwordSecret is now optional. viewer.username stays required, because it names the account the token command creates.

  • _medic.tpl: vigil.medic.required no longer requires passwordSecret.name. A new helper, vigil.medicGateway.tokenSecret, gives the token Secret's name. The chart never renders that Secret: no hook, no lookup, no minting. So helm upgrade can't overwrite what the operator put there.

  • medic-gateway.yaml: mounts one projected volume at /run/secrets with two secret sources, both optional: true:

    • the token Secret, as medic_gateway_token;
    • the password Secret, as medic_viewer_password, only when one is set.

    It keeps defaultMode: 0440 and the fsGroup, and uses no subPath and no env. VIGIL_MEDIC_GATEWAY_TOKEN_FILE is now set explicitly.

  • NOTES.txt: prints one command, kubectl exec … python -m core.auth.service_account token <user> | kubectl create secret generic <tokenSecret> --from-file=token=/dev/stdin --dry-run=client -o yaml | kubectl apply -f -. The old password steps are gone.

  • docs/medic/enable.md: the Helm section is rewritten to cover a fresh install with no password Secret, GitOps and external secret stores, and moving a site set up before tokens. The intro bullets now say how the gateway authenticates on each shape and describe token. The Compose text is unchanged (Compose: enable-compose.sh mints Medic's token, and the gateway starts with either credential file missing #4429).

Verification

Ran

  • helm lint and helm template with ci/default-values.yaml and Medic on:
    • With no password Secret, the volume has only the token source.
    • With passwordSecret.name set, it has both sources.
    • An empty viewer.username still fails, with the updated message.
  • A live run on kind (kindnet, NetworkPolicies on) using images built from this branch: the real backend with the chart's own Postgres and Redis, real Medic and the real gateway, and a stub agent worker. /_gw/status and a real read (GET /api/orchestrator/status) went through the gateway from Medic's pod. The command I ran was the one taken from helm get notes.
    1. Fresh install, no password Secret. All pods became Ready. The gateway reported {"state":"no_credential","credential":"none"} and the read returned 502. After running the printed command, the gateway reported credential: token within about 45 s and the read returned 200; state was ok shortly after. It was the same gateway pod, with 0 restarts.
    2. Upgrade from main's chart. I installed origin/main's chart with a medic-viewer password Secret and ran ensure: reads returned 200 on credential: password. Then I ran helm upgrade to this chart with the same values:
      • the rendered volume showed both optional sources;
      • reads still returned 200 on the password;
      • a direct password login to the backend returned 200.
    3. Moving the upgraded site. I ran the printed command (minted). The gateway moved to credential: token with the read returning 200, in the same pod with 0 restarts, and logged auth_credential previous=password → token. A password login then returned 401.

Did not run

  • medic-tests/kind/e2e.sh. It still installs with a password Secret, which this chart still accepts, and the CI Medic Helm workflow runs it.
  • No UI checks: nothing this PR changes renders on a screen.

Blocked by the machine

  • The chart's subchart dependencies were not in the checkout, so helm template and helm lint failed until I ran helm dependency build. The kind run strips the dependencies, as e2e.sh does.
  • I had to build the images by hand (vigil-medic, vigil-medic-gateway, vigil-backend) and create a kind cluster myself.
  • On my first attempt, the chart's pre-upgrade Job timed out: it waits for every pod carrying the release's labels to stop, and that included my stub agent worker. I scaled the stub down during helm upgrade. This was a problem in my test setup, not in the chart.

🤖 Generated with Claude Code

…at fills it

- values: medic.gateway.tokenSecret.{name,key}; name "" means
  <release>-medic-gateway-token. viewer.passwordSecret is now optional.
- The gateway mounts both Secrets through one projected volume, each source
  optional, no subPath, so it starts with neither (no_credential) and picks up a
  Secret filled later without a restart. VIGIL_MEDIC_GATEWAY_TOKEN_FILE is set.
- vigil.medic.required no longer requires the password Secret. The chart never
  renders the token Secret, so helm upgrade can't overwrite it.
- NOTES prints one command: kubectl exec ... service_account token <user>
  piped into kubectl create secret --dry-run=client -o yaml | kubectl apply.
- docs/medic/enable.md: Helm section rewritten (fresh install, GitOps and
  external stores, moving an upgraded site); intro covers the token.

Closes #4430

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@samarmstrong

Copy link
Copy Markdown
Collaborator Author

🏭 Handed the merge conflicts back to the agent that opened this (1 of 3): merge conflicts with main.

Resolve docs/medic/enable.md: Compose (#4458) and Helm (this PR) both
read with a host-minted token now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@samarmstrong
samarmstrong merged commit 481d35d into main Nov 16, 2026
26 checks passed
@samarmstrong
samarmstrong deleted the factory/4430-helm-the-gateway-mounts-a-token-c42e8c8a branch November 16, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

factory Opened by the software factory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Helm: the gateway mounts a token Secret, and the printed command fills it

1 participant