From 781d17b85cbb6f106233d972e4c0f0a50344d558 Mon Sep 17 00:00:00 2001 From: Thinking Chen Date: Mon, 4 Sep 2023 22:26:21 +0800 Subject: [PATCH] Add service account name in connection pooler (#2352) --- pkg/cluster/connection_pooler.go | 1 + pkg/cluster/connection_pooler_test.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/pkg/cluster/connection_pooler.go b/pkg/cluster/connection_pooler.go index d66a39b26..c551f0a8f 100644 --- a/pkg/cluster/connection_pooler.go +++ b/pkg/cluster/connection_pooler.go @@ -406,6 +406,7 @@ func (c *Cluster) generateConnectionPoolerPodTemplate(role PostgresRole) ( Tolerations: tolerationsSpec, Volumes: poolerVolumes, SecurityContext: &securityContext, + ServiceAccountName: c.OpConfig.PodServiceAccountName, }, } diff --git a/pkg/cluster/connection_pooler_test.go b/pkg/cluster/connection_pooler_test.go index 25cc40ef1..d0844951f 100644 --- a/pkg/cluster/connection_pooler_test.go +++ b/pkg/cluster/connection_pooler_test.go @@ -1000,6 +1000,7 @@ func TestPoolerTLS(t *testing.T) { ConnectionPoolerDefaultMemoryRequest: "100Mi", ConnectionPoolerDefaultMemoryLimit: "100Mi", }, + PodServiceAccountName: "postgres-pod", }, }, client, pg, logger, eventRecorder) @@ -1028,6 +1029,8 @@ func TestPoolerTLS(t *testing.T) { fsGroup := int64(103) assert.Equal(t, &fsGroup, deploy.Spec.Template.Spec.SecurityContext.FSGroup, "has a default FSGroup assigned") + assert.Equal(t, "postgres-pod", deploy.Spec.Template.Spec.ServiceAccountName, "need to add a service account name") + volume := v1.Volume{ Name: "my-secret", VolumeSource: v1.VolumeSource{