Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keycloak 26 enable internal connection #2386

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rickysway
Copy link

What this PR does / why we need it:
As of Keycloak 25 onwards, with the move to Hostname V2, for internal cluster Pod to Service communication you need to enable backchannelDynamic (effectively adding env var KC_HOSTNAME_BACKCHANNEL_DYNAMIC: 'true' to Keycloak), we opt for setting the env as a customer could potentially installed Keycloak 24 in another namespace after this installation, which will break their Keycloak 26 installation if we relied on backchannelDynamic due to the change of CRD
https://www.keycloak.org/server/hostname#_utilizing_an_internal_url_for_communication_among_clients

According to Keycloak Hostname V2 docs when spec.hostname.backchannelDynamic: true the hostname needs to be a URL and not just hostname, so adding https:// to the start of the hostname value
https://www.keycloak.org/server/hostname#_validations

Which issue(s) this PR fixes:
Fixes https://github.ibm.com/IBMPrivateCloud/roadmap/issues/65922

Special notes for your reviewer:
Unsure if the below section "backport" is needed

How to backport this PR to other branch:

  1. Add label to this PR with the target branch name backport <branch-name>
  2. The PR will be automatically created in the target branch after merging this PR
  3. If this PR is already merged, you can still add the label with the target branch name backport <branch-name> and leave a comment /backport to trigger the backport action

@ibm-ci-bot
Copy link
Collaborator

Welcome @rickysway! It looks like this is your first PR to IBM/ibm-common-service-operator 🎉

@ibm-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rickysway
Once this PR has been reviewed and has the lgtm label, please assign jeremy-cheng-stack for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ibm-ci-bot
Copy link
Collaborator

Hi @rickysway. Thanks for your PR.

I'm waiting for a IBM member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@@ -964,7 +964,7 @@ spec:
apiVersion: route.openshift.io/v1
kind: Route
name: keycloak
path: .spec.host
path: https://+.spec.host
Copy link
Author

@rickysway rickysway Feb 19, 2025

Choose a reason for hiding this comment

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

This does not work on Keycloak 22/24. Noting the url becomes https://https//........
This works on Keycloak 26 however

@YCShen1010
Copy link
Contributor

YCShen1010 commented Mar 4, 2025

Hello @rickysway, I think we could directly define .spec.additionalOptions in the Keycloak CR to enable KC_HOSTNAME_BACKCHANNEL_DYNAMIC equals to true instead, and then it will be present in the env in pod yaml.
Doc link: https://www.keycloak.org/server/all-config#category-hostname_v2
example:

data:
    spec:
    ...
    additionalOptions:                          <----- newly added
      - name: hostname-backchannel-dynamic
        value: "true"
    ...
    ...
    proxy:
      headers: xforwarded
    features:
      enabled:
        - token-exchange
        - admin-fine-grained-authz

When it is enabled as true, it requires https:// as a prefix for the hostname. We are going to enhance the ODLM templating logic to handle this, and I could open a new PR with this update later.
Thank you for pointing out these changes to us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants