From ebe602b1139d472d8ff5f2616a9a8d5d2580f582 Mon Sep 17 00:00:00 2001 From: Sebastian Florek Date: Thu, 30 Jan 2025 21:07:00 +0100 Subject: [PATCH] update osbuilder/osartifact --- api/v1alpha2/osartifact_types.go | 8 ++++++++ api/v1alpha2/zz_generated.deepcopy.go | 5 +++++ charts/osartifact/Chart.yaml | 2 +- charts/osartifact/templates/osartifact.yaml | 7 +++++++ charts/osartifact/values.yaml | 6 +++++- charts/osbuilder/Chart.yaml | 4 ++-- .../osbuilder/crds/build.kairos.io_osartifacts.yaml | 8 ++++++++ config/crd/bases/build.kairos.io_osartifacts.yaml | 8 ++++++++ controllers/osartifact_controller.go | 11 ++++++++--- 9 files changed, 52 insertions(+), 7 deletions(-) diff --git a/api/v1alpha2/osartifact_types.go b/api/v1alpha2/osartifact_types.go index 5a273c1..662b92e 100644 --- a/api/v1alpha2/osartifact_types.go +++ b/api/v1alpha2/osartifact_types.go @@ -80,6 +80,14 @@ type ExporterSpec struct { // ExtraEnvVars allows to append extra env vars to the exporter pods. // +optional ExtraEnvVars *[]corev1.EnvVar `json:"extraEnvVars,omitempty"` + + // Image is the image used for exporter pods + // +optional + Image string `json:"image,omitempty"` + + // ExtraArgs allows appending args to the exporter image. + // +optional + ExtraArgs []string `json:"extraArgs,omitempty"` } func (in *ExporterSpec) IsECRRegistry() bool { diff --git a/api/v1alpha2/zz_generated.deepcopy.go b/api/v1alpha2/zz_generated.deepcopy.go index 5585e09..c383179 100644 --- a/api/v1alpha2/zz_generated.deepcopy.go +++ b/api/v1alpha2/zz_generated.deepcopy.go @@ -46,6 +46,11 @@ func (in *ExporterSpec) DeepCopyInto(out *ExporterSpec) { } } } + if in.ExtraArgs != nil { + in, out := &in.ExtraArgs, &out.ExtraArgs + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExporterSpec. diff --git a/charts/osartifact/Chart.yaml b/charts/osartifact/Chart.yaml index 18eb170..85cd948 100644 --- a/charts/osartifact/Chart.yaml +++ b/charts/osartifact/Chart.yaml @@ -5,4 +5,4 @@ maintainers: - name: Plural email: support@plural.sh type: application -version: 0.6.2 \ No newline at end of file +version: 0.7.0 \ No newline at end of file diff --git a/charts/osartifact/templates/osartifact.yaml b/charts/osartifact/templates/osartifact.yaml index 92428c8..662a420 100644 --- a/charts/osartifact/templates/osartifact.yaml +++ b/charts/osartifact/templates/osartifact.yaml @@ -27,6 +27,13 @@ spec: {{- with .Values.exporter.extraEnvVars }} extraEnvVars: {{ . | toYaml | nindent 4 }} {{- end }} + {{- if .Values.exporter.image }} + image: {{ .Values.exporter.image }} + {{- end }} + {{ with .Values.exporter.extraArgs }} + extraArgs: + {{- . | toYaml | nindent 6 }} + {{- end }} registry: name: {{ .Values.exporter.registry.name }} type: {{ .Values.exporter.registry.type }} diff --git a/charts/osartifact/values.yaml b/charts/osartifact/values.yaml index 2f71390..fc0f3f9 100644 --- a/charts/osartifact/values.yaml +++ b/charts/osartifact/values.yaml @@ -61,11 +61,15 @@ extraCloudConfig: ~ exporter: serviceAccount: annotations: ~ - # Defines extra env vars that will be added to the exporter pob + # Defines extra env vars that will be added to the exporter pod # extraEnvVars: # - name: MY_ENV_VAR # value: myvalue extraEnvVars: [] + # Image used for exporter pods + image: ~ + # Allows appending args to the exporter image + extraArgs: [] registry: # Container registry DNS name where we should export packed ISO images name: ~ diff --git a/charts/osbuilder/Chart.yaml b/charts/osbuilder/Chart.yaml index 8b9e471..7c175d5 100644 --- a/charts/osbuilder/Chart.yaml +++ b/charts/osbuilder/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 name: osbuilder description: A Helm chart for osbuilder -appVersion: 0.3.0 -version: 0.1.14 +appVersion: 0.4.0 +version: 0.1.15 dependencies: - name: cert-manager version: v1.16.3 diff --git a/charts/osbuilder/crds/build.kairos.io_osartifacts.yaml b/charts/osbuilder/crds/build.kairos.io_osartifacts.yaml index 367ea5e..f264261 100644 --- a/charts/osbuilder/crds/build.kairos.io_osartifacts.yaml +++ b/charts/osbuilder/crds/build.kairos.io_osartifacts.yaml @@ -75,6 +75,11 @@ spec: Exporter when provided it will spawn an exporter job that pushes images built by the osbuilder to the provided registry. properties: + extraArgs: + description: ExtraArgs allows appending args to the exporter image. + items: + type: string + type: array extraEnvVars: description: ExtraEnvVars allows to append extra env vars to the exporter pods. @@ -196,6 +201,9 @@ spec: - name type: object type: array + image: + description: Image is the image used for exporter pods + type: string registry: description: Registry is a registry spec used to push the final images built by the osbuilder. diff --git a/config/crd/bases/build.kairos.io_osartifacts.yaml b/config/crd/bases/build.kairos.io_osartifacts.yaml index 367ea5e..f264261 100644 --- a/config/crd/bases/build.kairos.io_osartifacts.yaml +++ b/config/crd/bases/build.kairos.io_osartifacts.yaml @@ -75,6 +75,11 @@ spec: Exporter when provided it will spawn an exporter job that pushes images built by the osbuilder to the provided registry. properties: + extraArgs: + description: ExtraArgs allows appending args to the exporter image. + items: + type: string + type: array extraEnvVars: description: ExtraEnvVars allows to append extra env vars to the exporter pods. @@ -196,6 +201,9 @@ spec: - name type: object type: array + image: + description: Image is the image used for exporter pods + type: string registry: description: Registry is a registry spec used to push the final images built by the osbuilder. diff --git a/controllers/osartifact_controller.go b/controllers/osartifact_controller.go index e85b118..c811fb3 100644 --- a/controllers/osartifact_controller.go +++ b/controllers/osartifact_controller.go @@ -309,14 +309,19 @@ func (r *OSArtifactReconciler) checkExport(ctx context.Context, artifact *osbuil tag = "latest" } + image := artifact.Spec.Exporter.Image + if len(image) == 0 { + image = "gcr.io/kaniko-project/executor:latest" + } + container := corev1.Container{ Name: "exporter", - Image: "gcr.io/kaniko-project/executor:latest", - Args: []string{ + Image: image, + Args: append([]string{ "--context=/artifacts/", "--dockerfile=/artifacts/Dockerfile", fmt.Sprintf("--destination=%s/%s:%s", artifact.Spec.Exporter.Registry.Name, artifact.Spec.Exporter.Registry.Image.Repository, tag), - }, + }, artifact.Spec.Exporter.ExtraArgs...), VolumeMounts: []corev1.VolumeMount{ { Name: "artifacts",