Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/v1alpha1/provider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ type DeploymentSpec struct {
// +optional
Containers []ContainerSpec `json:"containers"`

// If specified, the pod's service account
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

// List of image pull secrets specified in the Deployment
// +optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,9 @@ spec:
between explicit zero and not specified. Defaults to 1.
minimum: 0
type: integer
serviceAccountName:
description: If specified, the pod's service account
type: string
tolerations:
description: If specified, the pod's tolerations.
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,9 @@ spec:
between explicit zero and not specified. Defaults to 1.
minimum: 0
type: integer
serviceAccountName:
description: If specified, the pod's service account
type: string
tolerations:
description: If specified, the pod's tolerations.
items:
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/operator.cluster.x-k8s.io_coreproviders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,9 @@ spec:
between explicit zero and not specified. Defaults to 1.
minimum: 0
type: integer
serviceAccountName:
description: If specified, the pod's service account
type: string
tolerations:
description: If specified, the pod's tolerations.
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,9 @@ spec:
between explicit zero and not specified. Defaults to 1.
minimum: 0
type: integer
serviceAccountName:
description: If specified, the pod's service account
type: string
tolerations:
description: If specified, the pod's tolerations.
items:
Expand Down
4 changes: 4 additions & 0 deletions internal/controller/component_customizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ func customizeDeployment(pSpec operatorv1.ProviderSpec, d *appsv1.Deployment) {
d.Spec.Template.Spec.Tolerations = dSpec.Tolerations
}

if dSpec.ServiceAccountName != "" {
d.Spec.Template.Spec.ServiceAccountName = dSpec.ServiceAccountName
}

if dSpec.ImagePullSecrets != nil {
d.Spec.Template.Spec.ImagePullSecrets = dSpec.ImagePullSecrets
}
Expand Down
17 changes: 17 additions & 0 deletions internal/controller/component_customizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,23 @@ func TestCustomizeDeployment(t *testing.T) {
return expectedDS, reflect.DeepEqual(inputDS.Template.Spec.Affinity, expectedDS.Template.Spec.Affinity)
},
},
{
name: "only serviceAccountName modified",
inputDeploymentSpec: &operatorv1.DeploymentSpec{
ServiceAccountName: "foo-service-account",
},
expectedDeploymentSpec: func(inputDS *appsv1.DeploymentSpec) (*appsv1.DeploymentSpec, bool) {
expectedDS := &appsv1.DeploymentSpec{
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
ServiceAccountName: "foo-service-account",
},
},
}

return expectedDS, reflect.DeepEqual(inputDS.Template.Spec.ServiceAccountName, expectedDS.Template.Spec.ServiceAccountName)
},
},
{
name: "only image pull secrets modified",
inputDeploymentSpec: &operatorv1.DeploymentSpec{
Expand Down