Skip to content

Commit 2bb6847

Browse files
authored
Merge pull request #174 from steve-fraser/main
✨ Add serviceAccountName to DeploymentSpec
2 parents 996d5d4 + c5a1bbf commit 2bb6847

7 files changed

+37
-0
lines changed

api/v1alpha1/provider_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ type DeploymentSpec struct {
115115
// +optional
116116
Containers []ContainerSpec `json:"containers"`
117117

118+
// If specified, the pod's service account
119+
// +optional
120+
ServiceAccountName string `json:"serviceAccountName,omitempty"`
121+
118122
// List of image pull secrets specified in the Deployment
119123
// +optional
120124
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`

config/crd/bases/operator.cluster.x-k8s.io_bootstrapproviders.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,9 @@ spec:
11541154
between explicit zero and not specified. Defaults to 1.
11551155
minimum: 0
11561156
type: integer
1157+
serviceAccountName:
1158+
description: If specified, the pod's service account
1159+
type: string
11571160
tolerations:
11581161
description: If specified, the pod's tolerations.
11591162
items:

config/crd/bases/operator.cluster.x-k8s.io_controlplaneproviders.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,9 @@ spec:
11551155
between explicit zero and not specified. Defaults to 1.
11561156
minimum: 0
11571157
type: integer
1158+
serviceAccountName:
1159+
description: If specified, the pod's service account
1160+
type: string
11581161
tolerations:
11591162
description: If specified, the pod's tolerations.
11601163
items:

config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,9 @@ spec:
11541154
between explicit zero and not specified. Defaults to 1.
11551155
minimum: 0
11561156
type: integer
1157+
serviceAccountName:
1158+
description: If specified, the pod's service account
1159+
type: string
11571160
tolerations:
11581161
description: If specified, the pod's tolerations.
11591162
items:

config/crd/bases/operator.cluster.x-k8s.io_infrastructureproviders.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,9 @@ spec:
11551155
between explicit zero and not specified. Defaults to 1.
11561156
minimum: 0
11571157
type: integer
1158+
serviceAccountName:
1159+
description: If specified, the pod's service account
1160+
type: string
11581161
tolerations:
11591162
description: If specified, the pod's tolerations.
11601163
items:

internal/controller/component_customizer.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ func customizeDeployment(pSpec operatorv1.ProviderSpec, d *appsv1.Deployment) {
108108
d.Spec.Template.Spec.Tolerations = dSpec.Tolerations
109109
}
110110

111+
if dSpec.ServiceAccountName != "" {
112+
d.Spec.Template.Spec.ServiceAccountName = dSpec.ServiceAccountName
113+
}
114+
111115
if dSpec.ImagePullSecrets != nil {
112116
d.Spec.Template.Spec.ImagePullSecrets = dSpec.ImagePullSecrets
113117
}

internal/controller/component_customizer_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,23 @@ func TestCustomizeDeployment(t *testing.T) {
202202
return expectedDS, reflect.DeepEqual(inputDS.Template.Spec.Affinity, expectedDS.Template.Spec.Affinity)
203203
},
204204
},
205+
{
206+
name: "only serviceAccountName modified",
207+
inputDeploymentSpec: &operatorv1.DeploymentSpec{
208+
ServiceAccountName: "foo-service-account",
209+
},
210+
expectedDeploymentSpec: func(inputDS *appsv1.DeploymentSpec) (*appsv1.DeploymentSpec, bool) {
211+
expectedDS := &appsv1.DeploymentSpec{
212+
Template: corev1.PodTemplateSpec{
213+
Spec: corev1.PodSpec{
214+
ServiceAccountName: "foo-service-account",
215+
},
216+
},
217+
}
218+
219+
return expectedDS, reflect.DeepEqual(inputDS.Template.Spec.ServiceAccountName, expectedDS.Template.Spec.ServiceAccountName)
220+
},
221+
},
205222
{
206223
name: "only image pull secrets modified",
207224
inputDeploymentSpec: &operatorv1.DeploymentSpec{

0 commit comments

Comments
 (0)