fix: always read Keycloak admin credentials fresh from secret#39
Merged
viniciusdc merged 3 commits intomainfrom Mar 5, 2026
Merged
fix: always read Keycloak admin credentials fresh from secret#39viniciusdc merged 3 commits intomainfrom
viniciusdc merged 3 commits intomainfrom
Conversation
loadCredentials() previously cached credentials permanently after the first read. If the Kubernetes secret was rotated, the operator would continue using stale credentials until the pod was restarted. Now credentials are always read fresh from the secret when AdminSecretName is configured. When no secret is configured, direct credentials (env vars) are used as a fallback. Fixes #28
🐳 Docker Image BuiltImage pushed to Quay.io for branch
You can test this PR by deploying: kubectl apply -f https://raw.githubusercontent.com/nebari-dev/nebari-operator/fix/keycloak-credential-refresh/config/default/
kubectl set image deployment/nebari-operator-controller-manager manager=quay.io/nebari/nebari-operator:fix-keycloak-credential-refresh -n nebari-operator-system |
Resolve conflict in keycloak_test.go by keeping both the LoadCredentials tests from this branch and the SyncClientScopes tests added on main.
Docker Image BuiltImage pushed to Quay.io for branch
You can test this PR by deploying: kubectl apply -f https://raw.githubusercontent.com/nebari-dev/nebari-operator/fix/keycloak-credential-refresh/config/default/
kubectl set image deployment/nebari-operator-controller-manager manager=quay.io/nebari/nebari-operator:fix-keycloak-credential-refresh -n nebari-operator-system |
viniciusdc
approved these changes
Mar 5, 2026
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.
Summary
loadCredentials()cached Keycloak admin credentials permanently after the first read, preventing secret rotation without pod restartsAdminSecretNameis configured, credentials are now always read fresh from the Kubernetes secretloadCredentials()including a test that proves secret rotation is picked upFixes #28
Test plan
TestKeycloakProvider_LoadCredentials_RefreshesOnSecretChange) proves credentials are refreshed after secret rotation