From e3bcf44c96cd49ebbb4d57fd3e7b12e9afa015b5 Mon Sep 17 00:00:00 2001 From: Jason Parraga Date: Tue, 3 Sep 2024 13:31:31 -0700 Subject: [PATCH] Actually reconcile service accounts (#324) Signed-off-by: Jason Parraga --- internal/controller/install/common_helpers.go | 10 +++++++++ .../controller/install/common_helpers_test.go | 22 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/internal/controller/install/common_helpers.go b/internal/controller/install/common_helpers.go index 9d6858df..3e693b5f 100644 --- a/internal/controller/install/common_helpers.go +++ b/internal/controller/install/common_helpers.go @@ -152,6 +152,16 @@ func (cc *CommonComponents) ReconcileComponents(newComponents *CommonComponents) cc.Service = nil } + if newComponents.ServiceAccount != nil { + cc.ServiceAccount.Labels = newComponents.ServiceAccount.Labels + cc.ServiceAccount.Annotations = newComponents.ServiceAccount.Annotations + cc.ServiceAccount.ImagePullSecrets = newComponents.ServiceAccount.ImagePullSecrets + cc.ServiceAccount.Secrets = newComponents.ServiceAccount.Secrets + cc.ServiceAccount.AutomountServiceAccountToken = newComponents.ServiceAccount.AutomountServiceAccountToken + } else { + cc.ServiceAccount = nil + } + if newComponents.ClusterRole != nil { cc.ClusterRole.Rules = newComponents.ClusterRole.Rules cc.ClusterRole.Labels = newComponents.ClusterRole.Labels diff --git a/internal/controller/install/common_helpers_test.go b/internal/controller/install/common_helpers_test.go index fd8f6d08..88107b0f 100644 --- a/internal/controller/install/common_helpers_test.go +++ b/internal/controller/install/common_helpers_test.go @@ -759,6 +759,27 @@ func makeCommonComponents() CommonComponents { }, } + automountServiceAccountToken := true + serviceAccount := corev1.ServiceAccount{ + ObjectMeta: metav1.ObjectMeta{ + Name: "some-name", + Namespace: "some-namespace", + Labels: map[string]string{"some-label-key": "some-label-value"}, + Annotations: map[string]string{"some-annotation-key": "some-annotation-value"}, + }, + ImagePullSecrets: []corev1.LocalObjectReference{ + { + Name: "some-image-pull-secret", + }, + }, + Secrets: []corev1.ObjectReference{ + { + Name: "some-secret", + }, + }, + AutomountServiceAccountToken: &automountServiceAccountToken, + } + pc := schedulingv1.PriorityClass{ Value: 1000, } @@ -768,6 +789,7 @@ func makeCommonComponents() CommonComponents { } return CommonComponents{ Deployment: &deployment, + ServiceAccount: &serviceAccount, PriorityClasses: []*schedulingv1.PriorityClass{&pc}, Secret: &secret, }