Skip to content

Commit e3bcf44

Browse files
authored
Actually reconcile service accounts (#324)
Signed-off-by: Jason Parraga <sovietaced@gmail.com>
1 parent d82cf81 commit e3bcf44

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

internal/controller/install/common_helpers.go

+10
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ func (cc *CommonComponents) ReconcileComponents(newComponents *CommonComponents)
152152
cc.Service = nil
153153
}
154154

155+
if newComponents.ServiceAccount != nil {
156+
cc.ServiceAccount.Labels = newComponents.ServiceAccount.Labels
157+
cc.ServiceAccount.Annotations = newComponents.ServiceAccount.Annotations
158+
cc.ServiceAccount.ImagePullSecrets = newComponents.ServiceAccount.ImagePullSecrets
159+
cc.ServiceAccount.Secrets = newComponents.ServiceAccount.Secrets
160+
cc.ServiceAccount.AutomountServiceAccountToken = newComponents.ServiceAccount.AutomountServiceAccountToken
161+
} else {
162+
cc.ServiceAccount = nil
163+
}
164+
155165
if newComponents.ClusterRole != nil {
156166
cc.ClusterRole.Rules = newComponents.ClusterRole.Rules
157167
cc.ClusterRole.Labels = newComponents.ClusterRole.Labels

internal/controller/install/common_helpers_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,27 @@ func makeCommonComponents() CommonComponents {
759759
},
760760
}
761761

762+
automountServiceAccountToken := true
763+
serviceAccount := corev1.ServiceAccount{
764+
ObjectMeta: metav1.ObjectMeta{
765+
Name: "some-name",
766+
Namespace: "some-namespace",
767+
Labels: map[string]string{"some-label-key": "some-label-value"},
768+
Annotations: map[string]string{"some-annotation-key": "some-annotation-value"},
769+
},
770+
ImagePullSecrets: []corev1.LocalObjectReference{
771+
{
772+
Name: "some-image-pull-secret",
773+
},
774+
},
775+
Secrets: []corev1.ObjectReference{
776+
{
777+
Name: "some-secret",
778+
},
779+
},
780+
AutomountServiceAccountToken: &automountServiceAccountToken,
781+
}
782+
762783
pc := schedulingv1.PriorityClass{
763784
Value: 1000,
764785
}
@@ -768,6 +789,7 @@ func makeCommonComponents() CommonComponents {
768789
}
769790
return CommonComponents{
770791
Deployment: &deployment,
792+
ServiceAccount: &serviceAccount,
771793
PriorityClasses: []*schedulingv1.PriorityClass{&pc},
772794
Secret: &secret,
773795
}

0 commit comments

Comments
 (0)