From 2fab4267f5ed289834347d3892fd4e5e98874a3f Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Fri, 10 Jan 2025 15:45:36 +0000 Subject: [PATCH] fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! General improvements --- chart/Chart.yaml | 4 ++-- chart/values.yaml | 2 +- .../clusterimageexport_controller.go | 17 +++++++++++++++++ internal/shared/jobs.go | 4 +--- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/chart/Chart.yaml b/chart/Chart.yaml index 962ac42..cc090d8 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -10,9 +10,9 @@ description: | type: application -version: 0.2.42 +version: 0.2.43 -appVersion: "0.2.42" +appVersion: "0.2.43" home: https://github.com/lukaszraczylo/kubernetes-images-sync-operator diff --git a/chart/values.yaml b/chart/values.yaml index 7d38789..fe6cead 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -12,7 +12,7 @@ sa: - ALL image: repository: ghcr.io/lukaszraczylo/kubernetes-images-sync-operator - tag: 0.2.42 + tag: 0.2.43 resources: limits: cpu: 500m diff --git a/internal/controller/raczylo.com/clusterimageexport_controller.go b/internal/controller/raczylo.com/clusterimageexport_controller.go index 04c479a..47ad5f2 100644 --- a/internal/controller/raczylo.com/clusterimageexport_controller.go +++ b/internal/controller/raczylo.com/clusterimageexport_controller.go @@ -9,6 +9,7 @@ import ( "github.com/go-logr/logr" appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -408,6 +409,21 @@ func (r *ClusterImageExportReconciler) runCleanupJob(ctx context.Context, cluste mergedAnnotations[k] = v } + // Set up environment variables for AWS configuration + envVars := []corev1.EnvVar{} + if clusterImageExport.Spec.Storage.StorageTarget == shared.STORAGE_S3 { + if clusterImageExport.Spec.Storage.S3.Region != "" { + envVars = append(envVars, corev1.EnvVar{ + Name: "AWS_REGION", + Value: clusterImageExport.Spec.Storage.S3.Region, + }) + envVars = append(envVars, corev1.EnvVar{ + Name: "AWS_DEFAULT_REGION", + Value: clusterImageExport.Spec.Storage.S3.Region, + }) + } + } + jobParams := shared.JobParams{ Name: normalisedImageName, Namespace: clusterImageExport.Namespace, @@ -418,6 +434,7 @@ func (r *ClusterImageExportReconciler) runCleanupJob(ctx context.Context, cluste ImagePullSecrets: clusterImageExport.Spec.ImagePullSecrets, BackoffLimit: &backoffLimit, TTLSecondsAfterFinished: &ttlSecondsAfterFinished, + EnvVars: envVars, } cleanupJob := shared.CreateJob(jobParams, func(raczylocomv1.ClusterImageExport) []string { return nil }) diff --git a/internal/shared/jobs.go b/internal/shared/jobs.go index 45cfdb2..39dad39 100644 --- a/internal/shared/jobs.go +++ b/internal/shared/jobs.go @@ -117,8 +117,6 @@ func SetupS3Params(s3Config raczylocomv1.ClusterImageStorageS3) []string { if s3Config.Endpoint != "" { params = append(params, fmt.Sprintf("--endpoint_url='%s'", s3Config.Endpoint)) } - if s3Config.Region != "" { - params = append(params, fmt.Sprintf("--region='%s'", s3Config.Region)) - } + // Region is now handled via environment variables return params }