diff --git a/test/Makefile b/test/Makefile index 10fd75da6..65e462240 100644 --- a/test/Makefile +++ b/test/Makefile @@ -104,6 +104,9 @@ REGISTRY_CREDENTIAL_FILE ?= KIBISHII_DIRECTORY ?= github.com/vmware-tanzu-experiments/distributed-data-generator/kubernetes/yaml/ IMAGE_REGISTRY_PROXY ?= +# Parameters for labels and annotations for Velero pods and service accounts. +POD_LABELS ?= +SA_ANNOTATIONS ?= # Flags to create an additional BSL for multiple credentials tests ADDITIONAL_BSL_PLUGINS ?= @@ -224,7 +227,9 @@ run-e2e: ginkgo --kibishii-directory=$(KIBISHII_DIRECTORY) \ --disable-informer-cache=$(DISABLE_INFORMER_CACHE) \ --image-registry-proxy=$(IMAGE_REGISTRY_PROXY) \ - --worker-os=$(WORKER_OS) + --worker-os=$(WORKER_OS) \ + --pod-labels=$(POD_LABELS) \ + --sa-annotations=$(SA_ANNOTATIONS) .PHONY: run-perf run-perf: ginkgo diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index fb2b594d0..ccbef8668 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -362,6 +362,19 @@ func init() { "linux", "test k8s worker node OS version, should be either linux or windows.", ) + + flag.StringVar( + &test.VeleroCfg.PodLabels, + "pod-labels", + "", + "comma-separated list of key=value labels to add to the Velero pod", + ) + flag.StringVar( + &test.VeleroCfg.ServiceAccountAnnotations, + "sa-annotations", + "", + "comma-separated list of key=value annotations to add to Velero service account", + ) } // Add label [SkipVanillaZfs]: diff --git a/test/types.go b/test/types.go index bc54948e4..01ea91c35 100644 --- a/test/types.go +++ b/test/types.go @@ -87,6 +87,8 @@ type VeleroConfig struct { CloudProvider string ObjectStoreProvider string VeleroNamespace string + PodLabels string + ServiceAccountAnnotations string AdditionalBSLProvider string AdditionalBSLBucket string AdditionalBSLPrefix string diff --git a/test/util/velero/install.go b/test/util/velero/install.go index 1cdaaa4f5..07e60a963 100644 --- a/test/util/velero/install.go +++ b/test/util/velero/install.go @@ -410,6 +410,14 @@ func installVeleroServer( args = append(args, fmt.Sprintf("--item-block-worker-count=%d", options.ItemBlockWorkerCount)) } + if len(options.PodLabels.Data()) > 0 { + args = append(args, "--pod-labels", options.PodLabels.String()) + } + + if len(options.ServiceAccountAnnotations.Data()) > 0 { + args = append(args, "--sa-annotations", options.ServiceAccountAnnotations.String()) + } + // Only version no older than v1.15 support --backup-repository-configmap. if options.BackupRepoConfigMap != "" && (semver.Compare(version, "v1.15") >= 0 || version == "main") { diff --git a/test/util/velero/velero_utils.go b/test/util/velero/velero_utils.go index 1fe362e7a..48b6ffe69 100644 --- a/test/util/velero/velero_utils.go +++ b/test/util/velero/velero_utils.go @@ -244,6 +244,12 @@ func getProviderVeleroInstallOptions(veleroCfg *VeleroConfig, io.VolumeSnapshotConfig = flag.NewMap() io.VolumeSnapshotConfig.Set(veleroCfg.VSLConfig) + io.PodLabels = flag.NewMap() + io.PodLabels.Set(veleroCfg.PodLabels) + + io.ServiceAccountAnnotations = flag.NewMap() + io.ServiceAccountAnnotations.Set(veleroCfg.ServiceAccountAnnotations) + io.Plugins = flag.NewStringArray(plugins...) io.Features = veleroCfg.Features io.DefaultVolumesToFsBackup = veleroCfg.DefaultVolumesToFsBackup