Skip to content

Add preview cluster-wide kubectl install for the operator - #46980

Merged
vmuzikar merged 13 commits into
keycloak:mainfrom
msander:feature/cluster-wide-operator
Jun 29, 2026
Merged

Add preview cluster-wide kubectl install for the operator#46980
vmuzikar merged 13 commits into
keycloak:mainfrom
msander:feature/cluster-wide-operator

Conversation

@msander

@msander msander commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Description

Adjust the non-OLM installation path to allow installing the Operator cluster-wide by using kubectl.

Support for watching all namespaces was already added in #22821, but it remained undocumented. This PR adds a dedicated overlay for that installation mode, updates the documentation, and adds integration test coverage for it.

closes: #46981

Motivation

Related to #43955.

A single cluster-wide Operator avoids installing one Operator per namespace and provides a documented path for environments where this setup is preferred.

Notes

  • experimental support for kubectl installs only
  • no OLM changes in this PR

@msander
msander force-pushed the feature/cluster-wide-operator branch from fe6b86b to 894b776 Compare March 9, 2026 12:02
@shawkins

shawkins commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

I think this warrants its own issue. It is staking out a middle ground we haven't yet talked about for cluster-wide mode - that is optionally (and possibly as unsupported) via non-olm mode. Please create an issue for this and we'll link it under #43955

As you can glean there hasn't been commitment yet on whether we are going to expose the simple cluster-wide mode. If you want to see this simple cluster wide mode supported in general please add comments about that to #43955 as well.

In part we're also waiting for results from #43954

cc @vmuzikar @mabartos

@msander

msander commented Mar 9, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, that makes sense.
I opened #46981 for experimental cluster-wide installation via the non-OLM / kubectl path.

@msander
msander marked this pull request as ready for review March 9, 2026 14:23
@msander
msander requested review from a team as code owners March 9, 2026 14:23

@vmuzikar vmuzikar 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.

@msander Thank you for the contribution. However, as @shawkins already mentioned, this first needs to be discussed properly on the issue as it has support implications on Keycloak.

@shawkins
shawkins force-pushed the feature/cluster-wide-operator branch from 894b776 to 6560da5 Compare June 3, 2026 16:33
@shawkins
shawkins requested review from shawkins and vmuzikar June 3, 2026 16:33
@shawkins

shawkins commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

I've made a couple of refinements to this pr. The first was to minimize the amount of duplication there is between our normal artifacts and what was in the new overlay. The second was to broaden how we are using kustomize - what was initially shown here was only valid if you were in the checked out operator directory after building the operator. This is because the kustomize file referenced the target directory as a resource. Instead what I think we need is to be able to install the operator like this:

kubectl apply -k 'github.com/keycloak/keycloak-k8s-resources/kubernetes?ref=version'

Or (which defaults to keycloak-operator namespace instead)

kubectl apply -k 'github.com/keycloak/keycloak-k8s-resources/overlays/cluster-wide?ref=version'

Putting the operator into a different namespace can then be done with a kustomize file similar to what is in this pr for switching to the default namespace, or we can just leave the current instuctions for now

kubectl -n custom-namespace apply -f https://raw.githubusercontent.com/keycloak/keycloak-k8s-resources/{version}/kubernetes/kubernetes.yml

If we have this in place, then we'll be able to change the docs for all the places we are currently referencing the operator installation:

https://github.com/search?q=org%3Akeycloak%20keycloak-k8s-resources&type=code

to be just kubectl apply -k 'github.com/keycloak/keycloak-k8s-resources/kubernetes?ref=version' - and then we won't have to update all those places again each time we add a new CRD for client v2 work.

@vmuzikar where is the job defined for adding resources to keycloak-k8s-resources? It would need to add the overlay directory moving forward.

The final change was to remove the use of kustomize from within the test code. I believe a goal in the test logic was to not directly call out to kubectl if possible.

@vmuzikar are you good with docs here that refer to this as an experimental feature that is only mentioned in the community docs? We can of course also address this in follow-ups under #49037

@shawkins
shawkins force-pushed the feature/cluster-wide-operator branch 3 times, most recently from 0bfe1e3 to f0fa14d Compare June 5, 2026 12:36
@keycloak-github-bot

Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.forms.BruteForceTest#testNoFailureResetForPermanentLockout

Keycloak CI - Base IT (5)

org.opentest4j.AssertionFailedError: Expected error event ==> expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
...

Report flaky test

@keycloak-github-bot keycloak-github-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@shawkins
shawkins force-pushed the feature/cluster-wide-operator branch from f0fa14d to fd78662 Compare June 11, 2026 13:52
Comment thread operator/src/main/overlays/cluster-wide/kustomization.yaml Outdated
Comment thread docs/guides/operator/installation.adoc Outdated
[source,bash]
----
kubectl create namespace keycloak-operator
kubectl apply -k 'github.com/keycloak/keycloak-k8s-resources/overlays/cluster-wide?ref={version}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this really referencing the correct repo? Shouldn't it be github.com/keycloak/keycloak/operator/overlays/cluster-wide?

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.

Is this really referencing the correct repo?

Yes, we'll need to update the job that is publishing to keycloak-k8s-resources - see #46980 (comment)

@shawkins

Copy link
Copy Markdown
Contributor

@keycloak/cloud-native this should be complete. My underlying assumption here is that we want to keep the single namespace installation the default behavior. If that changes later (needs of the helm chart, or if we want the cluster-wide to be the default) we can revisit this.

@shawkins

shawkins commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@vmuzikar updated to the Preview term again, and needed to remove trying to share the crds. It violates the security model of kustomize to make parent references to anything other that other kustomize directories - which we don't want to do in this case as that puts us back into making this an overlay.

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/operator-ci.yml
Comment thread docs/guides/operator/installation.adoc

@vmuzikar vmuzikar 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.

@shawkins Thanks for the updates. The only thing missing is the release notes (specifically for Kustomize, all namespace mode will be covered in the other PR), and single namespace mode test.

msander and others added 12 commits June 29, 2026 07:56
Signed-off-by: Marcel Sander <marcel.sander@actidoo.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steven Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
approach

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
@shawkins

Copy link
Copy Markdown
Contributor

shawkins Thanks for the updates. The only thing missing is the release notes (specifically for Kustomize, all namespace mode will be covered in the other PR), and single namespace mode test.

specifically for Kustomize, all namespace mode will be covered in the other PR

I am assuming that would happen in which ever PR goes in last - in particular the current all namespace kubectl instructions in the other PR will need to be updated, and it contains a release note with a general cluster-wide heading under which kubectl installs for community should be called out as well.

and single namespace mode test

Added.

Copilot AI review requested due to automatic review settings June 29, 2026 12:31
@shawkins
shawkins force-pushed the feature/cluster-wide-operator branch from 28feeeb to 18c49c1 Compare June 29, 2026 12:31

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread docs/guides/operator/installation.adoc Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Steven Hawkins <shawkins@redhat.com>
Copilot AI review requested due to automatic review settings June 29, 2026 12:42

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Comment thread operator/src/main/resources/application.properties
Comment thread operator/src/main/kubernetes/kustomization.yml
Comment thread .github/workflows/operator-ci.yml
Comment thread .github/workflows/operator-ci.yml
Comment thread .github/workflows/operator-ci.yml

@vmuzikar vmuzikar 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.

I am assuming that would happen in which ever PR goes in last - in particular the current all namespace kubectl instructions in the other PR will need to be updated, and it contains a release note with a general cluster-wide heading under which kubectl installs for community should be called out as well.

Ok, let's merge this and let's create some final release notes in the other PR.

LGTM. Thank you @msander and @shawkins.

@vmuzikar
vmuzikar enabled auto-merge (squash) June 29, 2026 16:14
@vmuzikar
vmuzikar merged commit a27ab58 into keycloak:main Jun 29, 2026
93 checks passed
sashyo pushed a commit to tide-foundation/keycloak-IGA that referenced this pull request Jul 20, 2026
…6980)

* Add experimental cluster-wide kubectl install support for the operator

Signed-off-by: Marcel Sander <marcel.sander@actidoo.com>

* standardizing the usage of kustomize and reducing artifact duplication

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* removing the process call to kustomize, and refining docs

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* running spotless

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* preventing both instances from having the same hostname

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* Apply suggestion from @shawkins

Signed-off-by: Steven Hawkins <shawkins@redhat.com>

* switching to dynamic detection of crds

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* switching to generating multiple installs rather than an overlay
approach

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* addressing review comments and adding a ci test

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* removing the crd dedup

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* updating the other ci waiting for crd

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* adding an own namespace test

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Steven Hawkins <shawkins@redhat.com>

---------

Signed-off-by: Marcel Sander <marcel.sander@actidoo.com>
Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Signed-off-by: Steven Hawkins <shawkins@redhat.com>
Co-authored-by: Steve Hawkins <shawkins@redhat.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

Support experimental cluster-wide operator installation by using kubectl

6 participants