Skip to content

Fix stale keycloak-admin-secret docs and remove orphaned Helm flags - #2155

Closed
Alan-Cha wants to merge 5 commits into
mainfrom
fix/stale-keycloak-admin-secret-docs
Closed

Alan-Cha wants to merge 5 commits into
mainfrom
fix/stale-keycloak-admin-secret-docs

Conversation

@Alan-Cha

@Alan-Cha Alan-Cha commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Removes the stale "Keycloak Admin Credentials for Agent Namespaces" section from docs/install.md that described a no-longer-existing mechanism (keycloak-admin-secret, keycloak.adminUsername, keycloak.adminPassword, keycloak.adminExistingSecret)
  • Replaces it with an accurate description of the actual mechanism: the kagenti-agent-oauth-secret-job reads keycloak-initial-admin at deploy time
  • Removes orphaned --set keycloak.adminUsername / --set keycloak.adminPassword flags from scripts/ocp/setup-kagenti.sh — these values don't exist in any chart template, so they were silently ignored on every upgrade

Root cause

The chart was already fixed (credentials are provisioned by a Job that reads keycloak-initial-admin directly), but the docs and the OCP setup script were never updated to match.

Test plan

  • Verify helm template still renders without error
  • Verify setup-kagenti.sh completes without referencing removed flags

Closes #1337

Assisted-By: Claude Code

@Alan-Cha Alan-Cha added the ready-for-ai-review Request automated AI code review from clawgenti label Jul 7, 2026

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Straightforward cleanup: removes the stale keycloak-admin-secret documentation section and the corresponding orphaned --set keycloak.adminUsername/adminPassword flags that were silently no-ops. All checks pass. Ready for human review.


Reviewed by clawgenti using github:pr-review

@Alan-Cha Alan-Cha added Ready for Review! ready-for-human-review AI review passed, ready for human reviewer labels Jul 9, 2026
@Alan-Cha
Alan-Cha force-pushed the fix/stale-keycloak-admin-secret-docs branch from aec6c66 to 38747bf Compare July 9, 2026 14:33
@Alan-Cha

Alan-Cha commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

This fix is a stepping stone toward #2174 — removing the credential-provisioning mechanism entirely in favor of SPIFFE-based Keycloak authentication.

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Straightforward doc and script cleanup — removes the stale keycloak-admin-secret section and the orphaned --set keycloak.adminUsername/adminPassword flags that were silently no-ops. All CI checks pass. Ready for human review.


Reviewed by clawgenti using github:pr-review

Comment thread docs/install.md Outdated
## Keycloak Admin Credentials for Agent Namespaces

The [AuthBridge](https://github.com/kagenti/kagenti-extensions/tree/main/authbridge) stack (separate sidecars or a single [combined `authbridge` container](authbridge-combined-sidecar.md)) needs Keycloak admin credentials for automatic OAuth2 client registration. These credentials are stored in a Kubernetes Secret called `keycloak-admin-secret` in each agent namespace.
The [AuthBridge](https://github.com/kagenti/kagenti-extensions/tree/main/authbridge) stack needs Keycloak admin credentials for automatic OAuth2 client registration. These credentials are provisioned automatically at install time by the `kagenti-agent-oauth-secret-job` Helm Job — no manual configuration is required.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The security note below says that admin credentials aren't needed and recommends a service account with limited permissions. Maybe say that instead of "needs admin account"?

Do we want the sidecar to have the power to do OAuth2 client registration? This seems scary from a security perspective -- can the Kagenti operator be tricked into giving Keycloak credentials to pods that aren't necessarily sidecars owned by the system? Id would prefer to never see any pods have Keycloak permissions that aren't under the management of a Kagenti service account.

@mrsabath mrsabath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The script change is correct and a genuine fix — but the docs rewrite is inaccurate and, as written, would make docs/install.md contradict docs/identity-guide.md in the same repo. Requesting changes on the docs half only.

✅ What's right

  • Removing --set keycloak.adminUsername / keycloak.adminPassword from scripts/ocp/setup-kagenti.sh — verified against charts/kagenti/values.yaml: those keys don't exist, so the flags were silently ignored on every run. Good cleanup.
  • The new adminSecretName / adminUsernameKey / adminPasswordKey values documented for the Job are real — they exist in values.yaml (lines 261-263) and are wired into templates/agent-oauth-secret-job.yaml (env KEYCLOAK_ADMIN_SECRET_NAME etc.). Accurate.

❌ What blocks (docs accuracy)

The rewrite's premise — that keycloak-admin-secret is a "no-longer-existing mechanism" — is not correct. That secret is still a live, security-relevant part of client registration; it moved, it wasn't removed (kagenti-operator#321):

  • docs/identity-guide.md (this PR doesn't touch it) still documents it as current: "the operator reads Keycloak admin credentials from keycloak-admin-secret in the operator namespace (kagenti-system)" (lines 264, 479, 628).
  • The operator's ClientRegistrationReconciler reads it, and the AuthBridge client-registration sidecar mounts it — see .github/scripts/kagenti-operator/36-fix-keycloak-admin.sh and .github/scripts/kind/91-run-authbridge-weather-e2e.sh ("the client-registration sidecar … mounts this secret from the pod's namespace. Since operator#321 the secret lives only in kagenti-system").

Separately, the PR conflates two different secrets: keycloak-admin-secret is the admin credential the reconciler/sidecar authenticate with; the kagenti-agent-oauth-secret-job reads keycloak-initial-admin to provision the per-agent OAuth client secrets. Replacing the whole admin-credentials section with a description of the OAuth-client Job drops the mechanism identity-guide.md still relies on.

Suggested fix: rather than deleting the section, retarget it to the actual current state — keycloak-admin-secret is now operator-managed in kagenti-system (operator#321), and cross-link identity-guide.md. The orphaned---set-flags removal is independently correct and can stay.

Areas reviewed: Docs (accuracy/cross-consistency), Shell, Commit/PR conventions
Commits: 1 commit, signed-off (DCO passes)
CI status: green except Deploy & Test (pending)
Verdict: REQUEST_CHANGES — 1 must-fix docs-accuracy issue; script change approved.

Comment thread docs/install.md Outdated
## Keycloak Admin Credentials for Agent Namespaces

The [AuthBridge](https://github.com/kagenti/kagenti-extensions/tree/main/authbridge) stack (separate sidecars or a single [combined `authbridge` container](authbridge-combined-sidecar.md)) needs Keycloak admin credentials for automatic OAuth2 client registration. These credentials are stored in a Kubernetes Secret called `keycloak-admin-secret` in each agent namespace.
The [AuthBridge](https://github.com/kagenti/kagenti-extensions/tree/main/authbridge) stack needs Keycloak admin credentials for automatic OAuth2 client registration. These credentials are provisioned automatically at install time by the `kagenti-agent-oauth-secret-job` Helm Job — no manual configuration is required.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must-fix. This declares keycloak-admin-secret gone, but it's still live — it moved to kagenti-system (kagenti-operator#321), it wasn't removed. docs/identity-guide.md (lines 264/479/628) documents the operator's ClientRegistrationReconciler reading it from the operator namespace, and the AuthBridge client-registration sidecar mounts it (.github/scripts/kind/91-run-authbridge-weather-e2e.sh).

Also, the kagenti-agent-oauth-secret-job reads keycloak-initial-admin to create the per-agent OAuth client secrets — a different secret and purpose than the keycloak-admin-secret admin credential the reconciler/sidecar use. Please retarget this section to the real current state (operator-managed keycloak-admin-secret in kagenti-system) and cross-link identity-guide.md, rather than describing it as removed.

Comment thread docs/install.md
--from-literal=KEYCLOAK_ADMIN_PASSWORD=admin \
--dry-run=client -o yaml | kubectl apply -f -
```
### Manual Sync (break-glass)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must-fix (internal contradiction). This break-glass snippet recreates keycloak-admin-secret — the very secret the top of the section calls "no-longer-existing" — and does so in the agent namespaces (team1/team2). Per operator#321 the operator now reads it from kagenti-system, so a manual sync into agent namespaces targets the wrong place. If a manual-sync path is kept, it should write to kagenti-system (or match wherever the sidecar mounts it), and the section shouldn't simultaneously claim the secret no longer exists.

@esnible esnible left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-scoped docs + script correction. I verified every removed and added value name against upstream/main:

  • ✅ keycloak.adminUsername / keycloak.adminPassword / keycloak.adminExistingSecret and the keycloak-admin-secret name are all gone from charts/kagenti/ — the removed --set flags in setup-kagenti.sh were genuine no-ops.
  • ✅ The new documented values (adminSecretName, adminUsernameKey, adminPasswordKey) exist in charts/kagenti/values.yaml.
  • ✅ kagenti-agent-oauth-secret-job exists and reads keycloak-initial-admin at deploy time (RBAC scoped to adminSecretName), matching the new description.
  • ✅ KC_ADMIN_FLAGS removed cleanly with no dangling references; the helm upgrade block is intact.

One suggestion inline about the break-glass snippet. Leaving as a comment (not an approval).

Author: Alan-Cha (MEMBER — maintainer) · Areas: Docs, Shell · Agent/IDE config: none · CI: passing (Deploy & Test still pending)

Assisted-By: Claude Code

Comment thread docs/install.md Outdated
KC_PASS=$(kubectl get secret keycloak-initial-admin -n keycloak -o jsonpath='{.data.password}' | base64 -d)

for ns in team1 team2; do
kubectl create secret generic keycloak-admin-secret -n $ns \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion — This break-glass snippet manually creates a secret named keycloak-admin-secret, but this PR's whole thesis is that keycloak-admin-secret is no longer part of the mechanism. The Job (kagenti-agent-oauth-secret-job) reads keycloak-initial-admin and registers the OAuth clients directly — it never consumes a per-namespace keycloak-admin-secret. So this manual kubectl create secret recreates an obsolete secret that nothing reads, and likely has no effect.

The helm upgrade re-run documented just above is the correct break-glass path. Consider dropping this kubectl create secret alternative so the fix doesn't reintroduce the exact stale-secret confusion it's removing.

@Alan-Cha

Alan-Cha commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

Thanks for the thorough review @mrsabath and @esnible. You're both right — I incorrectly described keycloak-admin-secret as removed when it had actually moved to kagenti-system (operator#321).

Fixed in the two new commits:

  • Rewritten section now accurately describes both secrets (admin creds in kagenti-system vs per-agent OAuth client secrets in agent namespaces), with a table distinguishing them and a cross-link to identity-guide.md
  • Break-glass snippet now targets kagenti-system with the correct key names (KEYCLOAK_ADMIN_USERNAME/KEYCLOAK_ADMIN_PASSWORD) as used in 36-fix-keycloak-admin.sh
  • Dropped the stale per-agent-namespace kubectl create secret alternative that was recreating the wrong secret in the wrong place

@clawgenti clawgenti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs and script fix looks correct at HEAD (f8e9dd25): keycloak-admin-secret is accurately described as living in kagenti-system, the two-secret table clearly separates admin creds from per-agent OAuth client secrets, the break-glass snippet targets the right namespace and key names, and the orphaned --set flags are cleanly removed from setup-kagenti.sh. All CI checks pass.

All checks pass. Ready for human review.


Reviewed by clawgenti using github:pr-review

@mrsabath mrsabath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both must-fix items from my earlier review are resolved — verified against upstream/main:

  • keycloak-admin-secret accuracy: the section no longer claims it was removed. The two-secret table correctly separates the operator-managed admin credential (keycloak-admin-secret in kagenti-system, per operator#321) from the per-agent OAuth client secrets, and cross-links identity-guide.md. Consistent with identity-guide.md lines 264/479/628.
  • Break-glass snippet: now targets kagenti-system with the same secret name and KEYCLOAK_ADMIN_USERNAME/KEYCLOAK_ADMIN_PASSWORD keys as the authoritative installer 36-fix-keycloak-admin.sh. Correct.

The orphaned --set keycloak.adminUsername/adminPassword removal was independently correct — those keys don't exist in values.yaml, so the flags were silent no-ops.

All static CI checks pass. Verdict: APPROVE.

Alan-Cha added 4 commits July 14, 2026 21:41
The kagenti-agent-oauth-secret-job already reads credentials from
keycloak-initial-admin at deploy time — no Helm value overrides are
needed. Remove the defunct adminUsername/adminPassword --set flags
from setup-kagenti.sh and update install.md to describe the actual
mechanism instead of the old hardcoded-credentials approach.

Closes #1337

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
… removed

Correct the install.md rewrite per reviewer feedback:
- keycloak-admin-secret is still live, it moved to kagenti-system
  (operator#321); it was not removed
- Clarify the two distinct secrets: keycloak-admin-secret (admin creds
  in kagenti-system) vs per-agent OAuth client secrets (agent namespaces)
- Fix break-glass snippet to target kagenti-system, not agent namespaces
- Cross-link identity-guide.md for the full client-registration flow

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
The keycloak-admin-secret uses KEYCLOAK_ADMIN_USERNAME and
KEYCLOAK_ADMIN_PASSWORD as keys (matching 36-fix-keycloak-admin.sh),
not the generic username/password keys from keycloak-initial-admin.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
…ence

- Rename section from 'Keycloak Admin Credentials for Agent Namespaces'
  to 'Keycloak Client Registration' to reflect the actual mechanism
- Add mode comparison table: client secrets (default) vs SPIFFE auth
  (recommended) with link to spiffe-keycloak-auth.md
- Remove stale reference to 'AuthBridge client-registration sidecar'
  (removed in #1422)
- Replace generic security note with concrete SPIFFE recommendation

Signed-off-by: Alan Cha <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
…eycloak-auth.md

Signed-off-by: Alan Cha <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
@Alan-Cha

Copy link
Copy Markdown
Member Author

Superseded by #2211 which consolidates the install.md fixes along with a full symmetric authentication guide.

@Alan-Cha Alan-Cha closed this Jul 15, 2026
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Jul 15, 2026
@Alan-Cha

Copy link
Copy Markdown
Member Author

All four comments are addressed in the superseding PR #2211.

The docs/authentication.md in #2211 now correctly describes the client-secrets flow:

  • The kagenti-agent-oauth-secret-job creates kagenti-keycloak-client-secret in each agent namespace with per-workload OAuth2 client credentials — it does not create keycloak-admin-secret in kagenti-system
  • The operator's ClientRegistrationReconciler reads keycloak-initial-admin directly from the keycloak namespace — there is no intermediate keycloak-admin-secret in the operator-managed path
  • The break-glass section has been replaced with an operator restart + log verification, removing the incorrect kubectl create secret keycloak-admin-secret command that targeted the wrong secret

pdettori pushed a commit to evaline-ju/rossoctl that referenced this pull request Jul 15, 2026
…n.md

- Create docs/authentication.md covering both auth modes with equal depth:
  - Client secrets (default): admin credential flow, provisioning,
    break-glass sync, how-it-works diagram
  - SPIFFE auth (recommended): JWT-SVID/Keycloak mechanics, operator
    bootstrap job flow, agent flow, prerequisites, Helm values
  - Shared sections: verification commands for both modes, troubleshooting

- Simplify docs/install.md: replace the verbose
  'Keycloak Admin Credentials for Agent Namespaces' section with a
  two-sentence summary that links to authentication.md

- scripts/ocp/setup-kagenti.sh: remove orphaned KC_ADMIN_FLAGS block
  (keycloak.adminUsername / keycloak.adminPassword chart values do not
  exist in templates; the bootstrap Job reads credentials directly from
  the keycloak-initial-admin Secret)

Supersedes PR rossoctl#2155 and PR rossoctl#2208.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Alan Cha <[email protected]>
@pdettori
pdettori deleted the fix/stale-keycloak-admin-secret-docs branch July 15, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Review! ready-for-ai-review Request automated AI code review from clawgenti ready-for-human-review AI review passed, ready for human reviewer

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: keycloak-admin-secret in agent namespaces uses stale credentials after RHBK operator upgrade

4 participants