+
Skip to content

set auto-mount service account token to false in keycloak pods #40605

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

KyriosGN0
Copy link
Contributor

fixes #38843

Signed-off-by: AvivGuiser <avivguiser@gmail.com>
@KyriosGN0
Copy link
Contributor Author

pretty sure the testNoAutoMountServiceAccount passed locally, just to be extra sure i will re-run it locally tomorrow

@ahus1
Copy link
Contributor

ahus1 commented Jun 19, 2025

For the Keycloak Multi-Site setup, IMHO we assume that the CA used in OpenShift is imported automatically so we can communicate with Infinispan securely.

Looping in @ryanemerson / @pruivo to ensure that the docs are updated for that.

Signed-off-by: AvivGuiser <avivguiser@gmail.com>
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
@pruivo
Copy link
Contributor

pruivo commented Jun 20, 2025

For mult-site HA, Infinispan requires /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
Documentation

@ahus1
Copy link
Contributor

ahus1 commented Jun 20, 2025

@pruivo - in addition to that, when Keycloak talks to Infinispan in that setup, it uses TLS. And to verify the Infinispan certificate, it needs to know about the CA. I remember there was some kind of mechanism.

Maybe @shawkins can refresh my memory here how Keycloak picks up that CA?

@pruivo
Copy link
Contributor

pruivo commented Jun 20, 2025

@ahus1 The operator automatically adds the certificate to the truststore:

// include the kube CA if the user is not controlling KC_TRUSTSTORE_PATHS via the unsupported or the additional
varMap.putIfAbsent(KC_TRUSTSTORE_PATHS, new EnvVarBuilder().withName(KC_TRUSTSTORE_PATHS).withValue(truststores).build());

@ahus1
Copy link
Contributor

ahus1 commented Jun 20, 2025

@pruivo, thank you, I was looking for that code snippet but didn't find it. So this option would be required in the Keycloak HA setup as described in https://www.keycloak.org/high-availability/deploy-keycloak-kubernetes

So if this is merged for the 26.3 release and we decide to update the docs in a follow-up issue, that follow-up issue should be a blocker for the 26.3 release.

@pruivo
Copy link
Contributor

pruivo commented Jun 20, 2025

@ahus1 How so? This PR is disabling the service account tokens (/var/run/secrets/kubernetes.io/serviceaccount/token ), and I don't find any relation to the service certificates in the Kubernetes docs.

@ahus1
Copy link
Contributor

ahus1 commented Jun 20, 2025

@pruivo - OK, then I was just worried without a reason. Then proceed here, and our tests in the cluster will show if it breaks. Sorry for the noise!

@pruivo
Copy link
Contributor

pruivo commented Jun 20, 2025

This is the only doc I found: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#opt-out-of-api-credential-automounting
If something breaks after this PR is merged, we will know the culprit 🤣

@vmuzikar
Copy link
Contributor

I don't find any relation to the service certificates in the Kubernetes docs

Based on #38843 (comment) it would appear that the CA cert is also not mounted when automountServiceAccountToken: false.

@KyriosGN0
Copy link
Contributor Author

@ahus1 How so? This PR is disabling the service account tokens (/var/run/secrets/kubernetes.io/serviceaccount/token ), and I don't find any relation to the service certificates in the Kubernetes docs.

the /var/run/secrets/kubernetes.io/serviceaccount/ca.crt (and that entire directory) is controlled by that flag, should i add the a clarification in some doc page that this option has to be true for multi-site setup in k8s?

@vmuzikar
Copy link
Contributor

should i add the a clarification in some doc page that this option has to be true for multi-site setup in k8s?

+1

Signed-off-by: AvivGuiser <avivguiser@gmail.com>
@KyriosGN0
Copy link
Contributor Author

added the automountServiceAccountToken: true to the example keycloak used in this doc

@KyriosGN0
Copy link
Contributor Author

Hey @vmuzikar would it be possible to get someone to take a look here?

Thanks in advance!

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.

Set automountServiceAccountToken: false on Keycloak pods
4 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载