Skip to content

Commit

Permalink
Copy "envFrom" from Velero server when creating maintenance jobs
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Hanson <[email protected]>
  • Loading branch information
a-really-great-username committed Oct 23, 2024
1 parent ebbeb7a commit ecc9c8e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/repository/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -433,6 +436,7 @@ func (m *manager) buildMaintenanceJob(
Args: args,
ImagePullPolicy: v1.PullIfNotPresent,
Env: envVars,
EnvFrom: envFromSources,
VolumeMounts: volumeMounts,
Resources: resources,
},
Expand Down
9 changes: 9 additions & 0 deletions pkg/util/velero/velero.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ecc9c8e

Please sign in to comment.