fix(info): use root-host for Keycloak OIDC issuer URL in tenant kubeconfig - #2704
Conversation
…onfig The kubeconfig generated for non-root tenants pointed `--oidc-issuer-url` at `keycloak.<TENANT>.<ROOT-DOMAIN>` because `$host` was sourced from `_namespace.host` (tenant-specific subdomain). Keycloak's ingress and cert live at `keycloak.<ROOT-DOMAIN>` (built from `_cluster.root-host`), so `kubectl oidc-login` failed TLS verification against the nginx-ingress default fake cert. The existing lookup-based override that tried to read `tenant-root`'s `spec.values.host` no longer triggers since PR #1787 migrated tenant-root to `valuesFrom` (Secret-backed), leaving `spec.values` empty. Use `_cluster.root-host` directly, matching what the dashboard gatekeeper template already does for the same Keycloak realm. Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe kubeconfig Helm template is simplified to resolve the host exclusively from cluster-level configuration. The template removes fallback logic that previously defaulted to namespace values and eliminates a conditional lookup of Flux HelmRelease resources that could override the host. ChangesKubeconfig Host Resolution Simplification
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where auto-generated kubeconfigs for non-root tenants were failing TLS verification during OIDC login. By standardizing the OIDC issuer URL to use the cluster's root-host, the configuration now correctly points to the valid Keycloak ingress, and redundant, non-functional lookup logic has been cleaned up to simplify the template. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on Gemini (@gemini-code-assist) comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request simplifies the kubeconfig.yaml template by removing a FluxCD-specific lookup block and streamlining the $host variable assignment. The feedback suggests improving code clarity by moving the $host definition inside the OIDC conditional block and applying defensive programming practices to handle potentially missing keys in .Values._cluster.
| @@ -1,4 +1,4 @@ | |||
| {{- $host := .Values._namespace.host | default (index .Values._cluster "root-host") }} | |||
| {{- $host := index .Values._cluster "root-host" }} | |||
There was a problem hiding this comment.
The variable $host is now only used within the OIDC configuration block (line 38) and is no longer reassigned since the lookup block was removed. To improve code clarity and keep the scope tight, consider moving its definition inside the {{- if $oidcEnabled }} block, consistent with other OIDC-specific variables like $apiServerEndpoint and $k8sCa. Additionally, following the defensive programming guidelines in the style guide, it is safer to provide a default or check for the existence of _cluster (e.g., index (.Values._cluster | default dict) "root-host") to avoid template errors if the key is missing.
References
- Enforce defensive programming: ensure appropriate null/nil checks or other language-idiomatic guards exist before object property accesses. (link)
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
LGTM — surgical fix, +1/-7. The bug is real, the dead-code removal claim checks out, and the fix matches the established pattern elsewhere in the chart tree.
Verified:
- Bug is real: pre-PR,
$hostdefaulted to.Values._namespace.host(e.g.tenant1.example.org), so the rendered OIDC issuer URL washttps://keycloak.tenant1.example.org/realms/cozy. But Keycloak's ingress and TLS cert live atkeycloak.<root-host>(e.g.keycloak.example.org), sooidc-loginhit nginx-ingress's default fake cert and failed TLS verification on every non-root tenant. - Cross-reference accurate:
packages/system/dashboard/templates/gatekeeper.yamluses exactly this shape —{{- $host := index .Values._cluster "root-host" }}followed by--oidc-issuer-url=https://keycloak.{{ $host }}/realms/cozy. The info kubeconfig now matches the same realm in the same way, so a tenant user and the dashboard both authenticate against the same issuer URL. - Dead-code claim accurate:
tenant-root.yamlusesvaluesFrom: Secret name: cozystack-values(verified inpackages/system/cozystack-basics/templates/tenant-root.yaml), sotenantRoot.spec.valuesis the empty struct, theand $tenantRoot $tenantRoot.spec $tenantRoot.spec.values $tenantRoot.spec.values.hostchain always short-circuits, and the override has been a no-op since #1787 (merged 2026-01-05) migrated tenants to the Secret-backedvaluesFrommechanism. Removing the block matches the post-#1787 reality. - Codex finds no regression. CI is green (Build + E2E + pre-commit + Verify generated all pass).
Bot finding is cosmetic, not a blocker:
- Gemini (low): "
$hostis now only used inside the$oidcEnabledblock; consider moving it inside." Pure style nit, can be deferred — keeping the host at the top mirrors the dashboardgatekeeper.yamlshape, which is consistent.
Non-blocking follow-up (not gating this fix): packages/extra/info/ has no tests/ directory, so the contract "OIDC issuer URL renders from _cluster.root-host, not _namespace.host" isn't pinned. Neighbouring extra packages do ship helm-unittest (packages/extra/{ingress,etcd,gateway}/tests/). Adding a minimal info/tests/kubeconfig_test.yaml that asserts the rendered Secret contains https://keycloak.<root-host>/realms/cozy and explicitly not the namespace host would pin this regression vector for next time. Out of scope for a 1-line backport-tagged fix; worth a separate task once the info package gets its test scaffolding.
What this PR does
The kubeconfig generated by the
infopackage for non-root tenants pointed--oidc-issuer-urlatkeycloak.<TENANT>.<ROOT-DOMAIN>, but Keycloak's ingress and cert live atkeycloak.<ROOT-DOMAIN>(built from_cluster.root-host).kubectl oidc-loginthen failed TLS verification against the nginx-ingress default fake cert, so the auto-generated kubeconfig was unusable for any non-root tenant.$hostwas being sourced from_namespace.host(tenant-specific subdomain) with a lookup-based override that tried to readtenant-root'sspec.values.host. That override has been dead since #1787 migratedtenant-roottovaluesFrom(Secret-backed) —spec.valuesis now always empty, so the override never fires.Source
$hostfrom_cluster.root-hostdirectly, matching whatpackages/system/dashboard/templates/gatekeeper.yamlalready does for the same Keycloak realm.Verified with
helm template tenant1 packages/extra/info -n tenant-tenant1 --set-string _namespace.host=tenant1.example.org --set-string _cluster.root-host=example.org ...— issuer URL is nowhttps://keycloak.example.org/realms/cozyregardless of the per-namespace host.Release note
Summary by CodeRabbit