fix(helm): stack-owned keycloak-internal Service so nginx survives Keycloak pod rolls - #1677
Open
doppelc wants to merge 1 commit into
Open
fix(helm): stack-owned keycloak-internal Service so nginx survives Keycloak pod rolls#1677doppelc wants to merge 1 commit into
doppelc wants to merge 1 commit into
Conversation
Contributor
|
@doppelc, thanks for opening this. Is there a reason we can't switch to the non headless service? I see in the design choices you've called out that we don't own the release name. That's true, but when deploying the stack, we know can figure out what it will be called and we can override the KEYCLOAK_URL. additionally, we are preparing to move off of the bitnami stack. My hesitation with the way proposed is that it will cause the registry to restart on keycloak restarts, which I understand fixes the issue you're experiencing, but I believe we have a cleaner way to do this. what do you think? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The charts set
KEYCLOAK_URLto the Bitnami Keycloak headless Service. The registry pod's nginx interpolates it into a literalproxy_passand resolves the hostname once at startup — and a headless Service's A record is the Keycloak pod IP itself. When the pod is replaced (upgrade, node roll, OOM), nginx keeps proxying to the dead IP: every/realms/*request (login, OIDC discovery, token mint) returns 503 until the registry pod is manually restarted.KEYCLOAK_URLis consumed viaenvFrom, snapshotted at pod start, so even a corrected Secret needs a pod roll to take effect.Reproduction (defaults, bundled Keycloak)
helm installthe stack chart with defaults.kubectl delete pod <release>-keycloak-0; wait for the replacement to become ready.curl <registry>/realms/<realm>/.well-known/openid-configuration→ 503, indefinitely.kubectl rollout restartthe registry deployment → 200 again.Fix
A stack-owned ClusterIP Service (
<release>-kc-int, port 8080) in front of the Keycloak pods — a stable virtual IP that kube-proxy retargets to the current pod on replacement. All fourkeycloakInternalUrlhelpers (stack, registry, auth-server, keycloak-configure) render that same release-scoped constant, and achecksum/keycloak-internal-urlpod annotation on registry and auth-server rolls exactly the pods that consume the URL viaenvFromwhen it changes.Design notes
nameOverride/fullnameOverrideand its port list is replaceable user values, so a derived URL can be silently broken by overrides orhelm upgrade --reuse-values. Owning the Service fixes name and port where no values override can reach.keycloak.podLabels/commonLabelsoverriding a selector label,keycloak.namespaceOverride) are rejected at render time./realms/<realm>/.well-known/openid-configurationwith 200 as soon as the replacement was ready.