Skip to content

Commit

Permalink
Velero ServiceAccount annotations support
Browse files Browse the repository at this point in the history
  • Loading branch information
kaovilai committed Feb 17, 2023
1 parent 0747309 commit 0fcf5ce
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions api/v1alpha1/oadp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ type VeleroConfig struct {
// +optional
// +kubebuilder:validation:Enum=trace;debug;info;warning;error;fatal;panic
LogLevel string `json:"logLevel,omitempty"`
// saAnnotations defines the annotations to be applied to the Velero service account
// +optional
SAAnnotations map[string]string `json:"saAnnotations,omitempty"`
}

// PodConfig defines the pod configuration options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ spec:
restoreResourcesVersionPriority:
description: restoreResourceVersionPriority represents a configmap that will be created if defined for use in conjunction with EnableAPIGroupVersions feature flag Defining this field automatically add EnableAPIGroupVersions to the velero server feature flag
type: string
saAnnotations:
additionalProperties:
type: string
description: saAnnotations defines the annotations to be applied to the Velero service account
type: object
type: object
type: object
features:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ spec:
restoreResourcesVersionPriority:
description: restoreResourceVersionPriority represents a configmap that will be created if defined for use in conjunction with EnableAPIGroupVersions feature flag Defining this field automatically add EnableAPIGroupVersions to the velero server feature flag
type: string
saAnnotations:
additionalProperties:
type: string
description: saAnnotations defines the annotations to be applied to the Velero service account
type: object
type: object
type: object
features:
Expand Down
6 changes: 4 additions & 2 deletions controllers/velero.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,10 @@ func (r *DPAReconciler) ReconcileVeleroDeployment(log logr.Logger) (bool, error)
}

func (r *DPAReconciler) veleroServiceAccount(dpa *oadpv1alpha1.DataProtectionApplication) (*corev1.ServiceAccount, error) {
annotations := make(map[string]string)
sa := install.ServiceAccount(dpa.Namespace, annotations)
if dpa.Spec.Configuration.Velero.SAAnnotations == nil {
dpa.Spec.Configuration.Velero.SAAnnotations = make(map[string]string)
}
sa := install.ServiceAccount(dpa.Namespace, dpa.Spec.Configuration.Velero.SAAnnotations)
sa.Labels = r.getDpaAppLabels(dpa)
return sa, nil
}
Expand Down

0 comments on commit 0fcf5ce

Please sign in to comment.