From ecc9c8e6ed151377af7d2acdb906cd8a8ff74723 Mon Sep 17 00:00:00 2001 From: Evan Hanson Date: Thu, 24 Oct 2024 10:48:09 +1300 Subject: [PATCH] Copy "envFrom" from Velero server when creating maintenance jobs Signed-off-by: Evan Hanson --- pkg/repository/manager/manager.go | 4 ++++ pkg/util/velero/velero.go | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/pkg/repository/manager/manager.go b/pkg/repository/manager/manager.go index a80d20c583..f590f2b145 100644 --- a/pkg/repository/manager/manager.go +++ b/pkg/repository/manager/manager.go @@ -368,6 +368,9 @@ func (m *manager) buildMaintenanceJob( // Get the environment variables from the Velero server deployment envVars := veleroutil.GetEnvVarsFromVeleroServer(deployment) + // Get the referenced storage from the Velero server deployment + envFromSources := veleroutil.GetEnvFromSourcesFromVeleroServer(deployment) + // Get the volume mounts from the Velero server deployment volumeMounts := veleroutil.GetVolumeMountsFromVeleroServer(deployment) @@ -433,6 +436,7 @@ func (m *manager) buildMaintenanceJob( Args: args, ImagePullPolicy: v1.PullIfNotPresent, Env: envVars, + EnvFrom: envFromSources, VolumeMounts: volumeMounts, Resources: resources, }, diff --git a/pkg/util/velero/velero.go b/pkg/util/velero/velero.go index bc52253365..79d74422f4 100644 --- a/pkg/util/velero/velero.go +++ b/pkg/util/velero/velero.go @@ -45,6 +45,15 @@ func GetEnvVarsFromVeleroServer(deployment *appsv1.Deployment) []v1.EnvVar { return nil } +// GetEnvFromSourcesFromVeleroServer get the environment sources from the Velero server deployment +func GetEnvFromSourcesFromVeleroServer(deployment *appsv1.Deployment) []v1.EnvFromSource { + for _, container := range deployment.Spec.Template.Spec.Containers { + // We only have one container in the Velero server deployment + return container.EnvFrom + } + return nil +} + // GetVolumeMountsFromVeleroServer get the volume mounts from the Velero server deployment func GetVolumeMountsFromVeleroServer(deployment *appsv1.Deployment) []v1.VolumeMount { for _, container := range deployment.Spec.Template.Spec.Containers {