From 745b2a18f1cd812c00b9683e11698101698b3510 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Tue, 1 Oct 2024 11:44:15 +0200 Subject: [PATCH] Also update the controller Signed-off-by: Itxaka --- api/v1alpha2/osartifact_types.go | 5 +++-- controllers/job.go | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/api/v1alpha2/osartifact_types.go b/api/v1alpha2/osartifact_types.go index 5156775..d182010 100644 --- a/api/v1alpha2/osartifact_types.go +++ b/api/v1alpha2/osartifact_types.go @@ -49,8 +49,9 @@ type OSArtifactSpec struct { CloudConfigRef *SecretKeySelector `json:"cloudConfigRef,omitempty"` GRUBConfig string `json:"grubConfig,omitempty"` - Bundles []string `json:"bundles,omitempty"` - OSRelease string `json:"osRelease,omitempty"` + Bundles []string `json:"bundles,omitempty"` + OSRelease string `json:"osRelease,omitempty"` + KairosRelease string `json:"kairosRelease,omitempty"` ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"` Exporters []batchv1.JobSpec `json:"exporters,omitempty"` diff --git a/controllers/job.go b/controllers/job.go index 2f07c4a..a1f024b 100644 --- a/controllers/job.go +++ b/controllers/job.go @@ -107,6 +107,29 @@ func osReleaseContainer(containerImage string) corev1.Container { } } +func kairosReleaseContainer(containerImage string) corev1.Container { + return corev1.Container{ + ImagePullPolicy: corev1.PullAlways, + Name: "kairos-release", + Image: containerImage, + Command: []string{"/bin/bash", "-cxe"}, + Args: []string{ + "cp -rfv /etc/kairos-release /rootfs/etc/kairos-release", + }, + VolumeMounts: []corev1.VolumeMount{ + { + Name: "config", + MountPath: "/etc/kairos-release", + SubPath: "kairos-release", + }, + { + Name: "rootfs", + MountPath: "/rootfs", + }, + }, + } +} + func (r *OSArtifactReconciler) newArtifactPVC(artifact *osbuilder.OSArtifact) *corev1.PersistentVolumeClaim { if artifact.Spec.Volume == nil { artifact.Spec.Volume = &corev1.PersistentVolumeClaimSpec{ @@ -358,6 +381,9 @@ func (r *OSArtifactReconciler) newBuilderPod(pvcName string, artifact *osbuilder if artifact.Spec.OSRelease != "" { podSpec.InitContainers = append(podSpec.InitContainers, osReleaseContainer(r.ToolImage)) } + if artifact.Spec.KairosRelease != "" { + podSpec.InitContainers = append(podSpec.InitContainers, kairosReleaseContainer(r.ToolImage)) + } if artifact.Spec.ISO || artifact.Spec.Netboot { podSpec.Containers = append(podSpec.Containers, buildIsoContainer)