Repository navigation
Description
Problem
After an upgrade, the keycloak-admin-secret in agent namespaces (team1, team2, etc.) may contain stale credentials (admin/admin) while the actual Keycloak admin is temp-admin with a randomly generated password. This causes the client-registration sidecar to fail with 401 errors when trying to register agents as OAuth clients in Keycloak.
Root cause
- The Helm chart defaults
keycloak.adminUsername: adminandkeycloak.adminPassword: adminincharts/kagenti/values.yaml(lines 149-165) - The RHBK operator creates
keycloak-initial-adminwithtemp-admin+ random password (documented in.github/scripts/kagenti-operator/36-fix-keycloak-admin.sh) - The installer has logic to read
keycloak-initial-adminand override the Helm values (main.ymllines 1918-1948), but this only works on a full installer run - Partial upgrades, manual
helm upgrade, or GitOps deployments skip this credential sync - The
keycloak-admin-secretis rendered by Helm with whatever values are in the release, creating a mismatch with the actual Keycloak admin credentials
Steps to reproduce
- Install Kagenti on OpenShift with RHBK operator managing Keycloak
- Perform a Helm upgrade without running the full Ansible installer (or with the credential override step failing silently)
- Deploy an agent -- the client-registration sidecar fails with 401 from Keycloak
Suggested fix
Option A (preferred): Change charts/kagenti/templates/agent-namespaces.yaml to NOT create keycloak-admin-secret with hardcoded values. Instead, use an init container or Job that reads keycloak-initial-admin from the Keycloak namespace at deploy time and syncs it to agent namespaces. The kagenti-agent-oauth-secret-job already has RBAC to read this secret -- extend it to also sync keycloak-admin-secret.
Option B: Make the installer's credential override step mandatory and fail-fast if it cannot read the source secret, rather than silently proceeding with defaults.
Option C: Remove hardcoded defaults from values.yaml entirely and require explicit credential configuration, failing early if not provided.
Workaround
Update the secret manually in each agent namespace:
KC_USER=$(oc get secret keycloak-initial-admin -n keycloak -o jsonpath='{.data.username}' | base64 -d)
KC_PASS=$(oc get secret keycloak-initial-admin -n keycloak -o jsonpath='{.data.password}' | base64 -d)
for ns in team1 team2; do
oc create secret generic keycloak-admin-secret -n $ns \
--from-literal=KEYCLOAK_ADMIN_USERNAME="$KC_USER" \
--from-literal=KEYCLOAK_ADMIN_PASSWORD="$KC_PASS" \
--dry-run=client -o yaml | oc apply -f -
doneEnvironment
- Platform: OpenShift 4.20.14
- Keycloak: RHBK operator-managed
- Previous creds:
admin/admin - Actual creds:
temp-admin/<generated>
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
📖 Fix stale keycloak-admin-secret docs and remove orphaned Helm flags
📖 Fix stale keycloak-admin-secret docs and remove orphaned Helm flags
mrsabath commentedon Jul 13, 2026
Resolved — closing.
The runtime bug (stale
admin/admininkeycloak-admin-secret→ 401 on client registration after an RHBK admin-password rotation/upgrade) is fixed inmain. The chart no longer creates a hardcoded admin secret; instead credentials are read live at deploy time from the operator-managedkeycloak-initial-admin— this is Option A from the report:charts/kagenti/values.yamldefaults tokeycloak.adminSecretName: keycloak-initial-admin(adminUsernameKey: username,adminPasswordKey: password).charts/kagenti/templates/agent-oauth-secret-job.yamlreads that secret at deploy time (RBAC scoped to it) and provisions per-agent OAuth clients from the live credentials.keycloak-admin-secretcreation remains anywhere in the chart, so the credentials can't drift out of sync across upgrades.Remaining follow-up is docs/script cleanup only — removing the now-inaccurate
keycloak-admin-secretsection fromdocs/install.mdand the orphaned--set keycloak.adminUsername/adminPasswordflags (silently ignored — those chart values no longer exist) fromscripts/ocp/setup-kagenti.sh. That's tracked in #2155 (approved) and can merge independently; it is not a blocker for this bug.Closing as fixed.
📖 Fix stale keycloak-admin-secret docs and remove orphaned Helm flags