Skip to content

[#2404] Custom ServiceAccount in Infinispan CR#2524

Open
tristantarrant wants to merge 1 commit into
infinispan:mainfrom
tristantarrant:2404/service_account
Open

[#2404] Custom ServiceAccount in Infinispan CR#2524
tristantarrant wants to merge 1 commit into
infinispan:mainfrom
tristantarrant:2404/service_account

Conversation

@tristantarrant
Copy link
Copy Markdown
Member

Closes #2404

@tristantarrant tristantarrant force-pushed the 2404/service_account branch from ca58ca2 to 15c4cc7 Compare May 29, 2026 12:26
+
The `spec.serviceAccountName` field sets the service account for {brandname} server pods and GossipRouter pods.
The `spec.configListener.serviceAccountName` field sets the service account for the ConfigListener pod.
Because the ConfigListener uses the Operator image rather than the {brandname} server image, it may require a different service account.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Different image may be one reason if for whatever reason the images are in different repositories but mainly the config listener service account needs access (roles) to manage Cache CRs. Cluster and Gossip service accounts do not require any roles (at least at the moment)

Because the ConfigListener uses the Operator image rather than the {brandname} server image, it may require a different service account.
+
When you specify `spec.configListener.serviceAccountName`, {ispn_operator} does not create its own service account for the ConfigListener.
However, it still creates the necessary Role and RoleBinding resources bound to the specified service account to ensure the ConfigListener has the required API permissions.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is anti pattern, you are giving away authorization secretly. If user want's to use his own service account, he needs to give it correct rbac roles and we need to document which ones are required and how to do that.

Annotations: annotationsForPod,
},
Spec: corev1.PodSpec{
ServiceAccountName: i.Spec.ServiceAccountName,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We might want to do a validation of SA existence and either emit an event if the SA does not exist or set a condition the SA is missing and loop reconciliation till it exists.

At the moment it just creates a StatefulSet with a error pod with missing ServiceAccount (Not 100% sure). Which is okay as well and we may keep it as is for now but generally I'd say it's better to accumulate issues directly at the Infinispan CR if we are able to detect them.

assert.Equal(saName, pod.Spec.ServiceAccountName)
}

func TestServiceAccountNameUpdate(t *testing.T) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This test is failing because required changes to pkg/reconcile/pipeline/infinispan/handler/manage/statefulset_updates.go reponsible for taking care of updates are missing

@@ -0,0 +1,6 @@
kind: Infinispan
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's not forget on ServiceAccount for Batches, Backups and Restores which spin up pods as well.

For those I'd say the general strategy should be to use any serviceAccount configured for target cluster (Infinispan CR) if present and maybe add an option to override with spec.serviceAccountName. Question is should we add an option to override the serviceAccount for the GossipRouter as well? I'd say not mandatory, at least not now.

@tristantarrant tristantarrant force-pushed the 2404/service_account branch from 15c4cc7 to ebcbe4b Compare June 5, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow the Infinispan pod's ServiceAccount to be configured in the Infinispan CR

2 participants