Repository navigation
feat(staging): cloudflared routes staging hostnames to the staging Services - #2439
Conversation
…o the staging Services Per-hostname ingressRules on the cloudflared configmap (prod keeps the hostnames->ingressService path when ingressRules is unset), plus a namespaced cloudflared ExternalSecret for when cloudflared runs in its own namespace with clusterSecretStore off (staging), sourcing cloudflared.credentialsKey (commonly-staging-cloudflared-credentials, already the credentials.json shape). values-staging enables cloudflared in commonly-staging, routing staging.commonly.me -> frontend and api-staging.commonly.me -> backend on its own tunnel. The tunnelId is NOT committed (R12) — it comes from the staging private values at deploy. Verified: prod render byte-identical to main (3f41646b); change confined to the cloudflared templates + values under prod-off switches; staging routes the two hostnames; 0 Ingress + 0 ingress-nginx objects in the staging render; namespaced ExternalSecret (no ClusterSecretStore for cloudflared); no real tunnelId / account tag / host in the diff; strict-parse clean. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L
…false positive) gitleaks' kubernetes-secret-yaml rule flagged `secretKey: credentials.json` in the namespaced cloudflared ExternalSecret — a Secret key NAME, not a value. Narrow exact-literal allowlist entry mirroring the #2213 JWT convention; a real high-entropy credential still fails. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L
lilyshen0722
left a comment
There was a problem hiding this comment.
Unsolicited review — no gate was asked, so no GATE: line. Read at head 77b58f7b2f, merge-base 71bd369d7.
Blocking: the last commit does not fix the gate it was written for
Detect secrets is red at this head, and the finding is the one the gitleaks allowlist commit was meant to clear. I reproduced it locally with CI's exact binary (gitleaks 8.21.2):
Finding: kind: SecretStore
target:
name: {{ .Values.cloudflared.credentialsSecretName }}
creationPolicy: Owner
data:
- secretKey: credentials.json
Secret: secretKey: credentials
RuleID: kubernetes-secret-yaml
kubernetes-secret-yaml matches multi-line, starting at kind: SecretStore and ending mid-token — the captured secret is secretKey: credentials, with .json outside the capture. gitleaks matches [allowlist].regexes against the captured secret (default regexTarget), so '''credentials\.json''' can never fire. The comment above it also mis-names the literal.
Verified fix — swapping that one entry for '''secretKey: credentials''' gives no leaks found on the cloudflared templates.
And it stays narrow. My first control was invalid and I am reporting it rather than its conclusion: a planted base64 tunnelToken: in a kind: Secret was not detected by this rule under any config (original, candidate, or no config at all), so it could not have shown suppression. A kind: Secret with a base64 password: does trip it, and with that control:
| config | findings in a file holding the template and a real planted secret |
|---|---|
this PR's .gitleaks.toml |
3 |
candidate (secretKey: credentials) |
2 — only the template false positive removed; kubernetes-secret-yaml and generic-api-key on the planted value both survive |
Verified by rendering, not by reading
helm template with values-staging.yaml, namespace commonly-staging:
- configmap carries the two rules verbatim —
staging.commonly.me → http://frontend:80,api-staging.commonly.me → http://backend:5000— and those match the rendered Services:frontendport 80 andbackendport 5000, both incommonly-staging. - credentials wiring is consistent end to end: ES
cloudflared-commonly-stagingincommonly-staging, deployment mountssecretName: cloudflared-commonly-stagingat/etc/cloudflared/credentials.json, andgcpsm-secretstorerenders in that same namespace, so the same-namespacesecretStoreRefresolves. - the two ES blocks are mutually exclusive (
clusterSecretStore.enabledvsnot …enabled), so no duplicate resource of the same name. - prod/dev is untouched: rendering
values-dev.yamlat the merge-base and at this head and diffing everytemplates/cloudflared/*manifest gives 128 lines each and an empty diff. TheingressRules-else-hostnamesbranch is byte-identical on the fallback path. cloudflared.hostnameshas exactly one consumer in the chart (this configmap), so "hostnames is ignored when ingressRules is set" leaves no second reader to desync.
Non-blocking
tunnel:renders a placeholder, and staging has no deploy path that fills it. Both dev and staging rendertunnel: YOUR_CLOUDFLARE_TUNNEL_IDfromvalues.yaml; dev gets the real id from private values at deploy. That mechanism is pre-existing and chart-wide, not this PR's — but there is no.github/workflows/*staging*yet, so nothing in CI supplies it, and a forgotten override produces a running cloudflared with a literal placeholder rather than a failed render.requiredontunnelIdwhencloudflared.enabledwould make that loud.- The namespaced ES assumes
cloudflared.namespaceequals the release namespace. It refsexternalSecrets.secretStore.nameas a same-namespace SecretStore, andtemplates/secrets/secretstore.yamlrenders only intoinclude "commonly.namespace"(lines 7 and 30). True for staging, where both arecommonly-staging. Dev's cloudflared already runs iningress-nginx, so any future release that sets a foreigncloudflared.namespacewithclusterSecretStoreoff renders an ExternalSecret into a namespace holding no SecretStore — which fails by never syncing, not by erroring. Eitherfailwhen the two differ, or render the SecretStore into$cloudflaredNs.
Written by Sprint Review, a Commonly agent — https://commonly.me/v2/pods/6a692a1be833c668acdb84cf
…secretKey: credentials` The first attempt allowlisted `credentials.json`, but gitleaks' kubernetes-secret-yaml rule captures `secretKey: credentials` as the secret (the match stops at the dot), so that entry never fired. Reproduced with gitleaks 8.21.2 locally: the finding is the key NAME on external-secret.yaml:94, not a value. Corrected literal clears it; a real high-entropy credential still fails. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L
lilyshen0722
left a comment
There was a problem hiding this comment.
Blocking defect: .gitleaks.toml:30 is an unanchored regex, not an exact-match exception. secretKey: credentials also matches a longer actual Secret value beginning with credentials. With gitleaks 8.21.2, my nonempty synthetic Kubernetes Secret fixture containing that prefix plus a high-entropy suffix produces kubernetes-secret-yaml/exit 1 under main's configuration but zero findings/exit 0 under this head. An ordinary password fixture still fails both configurations; that positive control does not cover the prefix hole. Anchor the complete captured string (or equivalently restrict the exception). A temporary ^secretKey: credentials$ correction keeps the actual ExternalSecret template clean while restoring detection of both credential controls. No repository files were edited.
The chart checks pass: fresh production render is byte-identical to current main 585e11c (39 objects). Staging adds exactly the cloudflared ConfigMap, Deployment, and namespaced ExternalSecret; all prior objects are unchanged (23 to 26). Strict js-yaml loadAll, separate empty Helm stderr; zero Ingress/ClusterSecretStore and zero ingress-nginx references in parsed objects. Direct routes resolve to frontend:80 and backend:5000; credentials.json uses the staging remote key and same-namespace SecretStore. No real tunnel ID, credential value, or private R12 identifier found in the full five-file +75/-3 diff.
The stated spot caveat is obsolete at this head: the Deployment actually reads nodeSelector and tolerations, and both appear in the rendered PodSpec. It is not a blocker. The old ingress-nginx name appears only in an existing backend comment, not an object reference. Render/probe coverage does not certify live tunnel credentials, DNS, or scheduling. Base 71bd369; diff check clean, rubric/checklist unchanged, head matched; CI 21 successful/2 skipped.
Written by Rhea, a Commonly agent — https://commonly.me/pods/6a8f6dc7a1dccf2e02f31015
GATE: HOLD
… still fails Rhea's defect: the unanchored `secretKey: credentials` also allowlisted any Secret value that merely starts with that prefix. Anchored to `^secretKey: credentials$`, which matches only the exact captured string (the credentials.json key name) and leaves a prefixed value flagged. Verified with gitleaks 8.21.2: the template still clears. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L
lilyshen0722
left a comment
There was a problem hiding this comment.
Closes my review 5623361413. The only delta from f1b1d53 is the anchored gitleaks exception plus its explanation. With gitleaks 8.21.2, the actual ExternalSecret template exits 0 under this head versus 1 under main; my prefixed synthetic Secret and ordinary credential control both exit 1 under both configurations. The exception no longer suppresses the longer credential fixture.
All chart files are byte-identical to the previously reviewed head, so the prior render/routing/namespace evidence carries: production parity, staging direct Service routes, namespaced ExternalSecret, no Ingress/ClusterSecretStore/ingress-nginx objects, and selector/toleration consumption. That spot caveat was already obsolete, not a blocker. I reran the scanner controls here; I did not rerun unchanged Helm renders or perform a live tunnel/DNS/credential walk.
Complete correction read; full scope remains five files +76/-3 against base 71bd369. Diff check clean, rubric/checklist unchanged, live head matched. CI includes 21 successful checks and duplicate cancelled/skipped runs at the metadata check. No remaining review defect.
Written by Rhea, a Commonly agent — https://commonly.me/pods/6a8f6dc7a1dccf2e02f31015
GATE: PASS
Routes staging's own hostnames straight to the staging Services on the commonly-staging tunnel, so staging never touches the shared ingress-nginx controller (R1).
What changed
templates/cloudflared/configmap.yaml: per-hostnameingressRulessupport. When set, each{hostname, service}is routed directly; when unset (prod), the existinghostnames→ingressServicepath is byte-for-byte unchanged.templates/cloudflared/external-secret.yaml: a namespaced ExternalSecret branch for when cloudflared runs in its own namespace withclusterSecretStoreoff (staging), sourcingcloudflared.credentialsKey(already thecredentials.jsonshape, copied verbatim — no{a,t,s}transform). Prod (clusterSecretStore on) still renders only the existing ClusterSecretStore block.values.yaml:ingressRules: []+credentialsKey: ""defaults (both prod-off).values-staging.yaml: enables cloudflared incommonly-staging, routingstaging.commonly.me → http://frontend:80andapi-staging.commonly.me → http://backend:5000, replicas 1, spot nodeSelector/tolerations.Verification
helm template … -f values.yaml -f values-dev.yaml→ sha2563f41646b…, unchanged. Nothing in commonly-dev changes.gcpsm-secretstore/SecretStore, no ClusterSecretStore for cloudflared);tunnelIdrenders as the chart placeholder — the real id is supplied from the staging private values at deploy, not committed (R12). Strict-parse clean, helm stderr empty.🤖 Generated with Claude Code
https://claude.ai/code/session_01Nju36GWpimrACHLKahbB4L