mirror of
https://github.com/kairos-io/osbuilder.git
synced 2025-08-02 08:06:24 +00:00
add support for file bundles
This commit is contained in:
parent
13a524daa8
commit
77a2bbb555
@ -60,9 +60,10 @@ type OSArtifactSpec struct {
|
||||
CloudConfigRef *SecretKeySelector `json:"cloudConfigRef,omitempty"`
|
||||
GRUBConfig string `json:"grubConfig,omitempty"`
|
||||
|
||||
Bundles []string `json:"bundles,omitempty"`
|
||||
OSRelease string `json:"osRelease,omitempty"`
|
||||
KairosRelease string `json:"kairosRelease,omitempty"`
|
||||
Bundles []string `json:"bundles,omitempty"`
|
||||
FileBundles map[string]string `json:"fileBundles,omitempty"`
|
||||
OSRelease string `json:"osRelease,omitempty"`
|
||||
KairosRelease string `json:"kairosRelease,omitempty"`
|
||||
|
||||
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
|
||||
Exporters []batchv1.JobSpec `json:"exporters,omitempty"`
|
||||
|
@ -108,6 +108,13 @@ func (in *OSArtifactSpec) DeepCopyInto(out *OSArtifactSpec) {
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.FileBundles != nil {
|
||||
in, out := &in.FileBundles, &out.FileBundles
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.ImagePullSecrets != nil {
|
||||
in, out := &in.ImagePullSecrets, &out.ImagePullSecrets
|
||||
*out = make([]v1.LocalObjectReference, len(*in))
|
||||
|
@ -7116,6 +7116,10 @@ spec:
|
||||
- template
|
||||
type: object
|
||||
type: array
|
||||
fileBundles:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
gceImage:
|
||||
type: boolean
|
||||
grubConfig:
|
||||
|
@ -28,7 +28,7 @@ data:
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
client_max_body_size 11000M;
|
||||
client_max_body_size 21000M;
|
||||
|
||||
#access_log /var/log/nginx/host.access.log main;
|
||||
|
||||
|
@ -13,7 +13,7 @@ image:
|
||||
# controller image to be used. Leave empty to use
|
||||
repository: ghcr.io/pluralsh/osbuilder
|
||||
# tag of the controller image. Leave empty to use chart's AppVersion
|
||||
tag: sha-29922d3
|
||||
tag:
|
||||
|
||||
toolsImage:
|
||||
repository: "quay.io/kairos/auroraboot"
|
||||
|
@ -7116,6 +7116,10 @@ spec:
|
||||
- template
|
||||
type: object
|
||||
type: array
|
||||
fileBundles:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
gceImage:
|
||||
type: boolean
|
||||
grubConfig:
|
||||
|
@ -6,21 +6,41 @@ stringData:
|
||||
userdata: |
|
||||
#cloud-config
|
||||
hostname: plural-edge-{{ trunc 10 .MachineID }}
|
||||
|
||||
users:
|
||||
- name: "kairos"
|
||||
passwd: "kairos"
|
||||
passwd: kairos
|
||||
groups: [ "admin" ]
|
||||
|
||||
write_files:
|
||||
- path: /etc/rancher/k3s/registries.yaml
|
||||
permissions: "0644"
|
||||
content: |
|
||||
mirrors:
|
||||
"*":
|
||||
|
||||
k3s:
|
||||
enabled: true
|
||||
replace_args: true
|
||||
args:
|
||||
- --node-name=kairos
|
||||
- --embedded-registry
|
||||
- --disable=traefik,servicelb
|
||||
|
||||
bundles:
|
||||
- targets:
|
||||
- run://ghcr.io/pluralsh/kairos-plural-bundle:0.1.4
|
||||
- targets:
|
||||
- run:///plural-bundle.tar
|
||||
local_file: true
|
||||
- targets:
|
||||
- run:///plural-images-bundle.tar
|
||||
local_file: true
|
||||
- targets:
|
||||
- run:///plural-trust-manager-bundle.tar
|
||||
local_file: true
|
||||
|
||||
plural:
|
||||
token: ""
|
||||
url: console.plrl-dev-aws.onplural.sh
|
||||
token:
|
||||
url: https://console.plrl-dev-aws.onplural.sh
|
||||
---
|
||||
kind: OSArtifact
|
||||
apiVersion: build.kairos.io/v1alpha2
|
||||
@ -30,8 +50,10 @@ spec:
|
||||
imageName: "quay.io/kairos/alpine:3.19-standard-arm64-rpi4-v3.2.4-k3sv1.31.3-k3s1"
|
||||
iso: true
|
||||
model: rpi4
|
||||
bundles:
|
||||
- ghcr.io/pluralsh/kairos-plural-bundle:0.1.4
|
||||
fileBundles:
|
||||
plural-bundle: ghcr.io/pluralsh/kairos-plural-bundle:0.1.4
|
||||
plural-images-bundle: ghcr.io/pluralsh/kairos-plural-images-bundle:0.1.1
|
||||
plural-trust-manager-bundle: ghcr.io/pluralsh/kairos-plural-trust-manager-bundle:0.1.0
|
||||
cloudConfigRef:
|
||||
name: cloud-config
|
||||
key: userdata
|
||||
|
@ -19,11 +19,10 @@ package controllers
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
osbuilder "github.com/kairos-io/osbuilder/api/v1alpha2"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
func unpackContainer(id, containerImage, pullImage string) corev1.Container {
|
||||
@ -48,6 +47,22 @@ func unpackContainer(id, containerImage, pullImage string) corev1.Container {
|
||||
}
|
||||
}
|
||||
|
||||
func unpackFileContainer(id, pullImage, name string) corev1.Container {
|
||||
return corev1.Container{
|
||||
ImagePullPolicy: corev1.PullAlways,
|
||||
Name: fmt.Sprintf("pull-image-%s", id),
|
||||
Image: "gcr.io/go-containerregistry/crane:latest",
|
||||
Command: []string{"crane"},
|
||||
Args: []string{"--platform=linux/arm64", "pull", pullImage, fmt.Sprintf("/rootfs/oem/%s.tar", name)},
|
||||
VolumeMounts: []corev1.VolumeMount{
|
||||
{
|
||||
Name: "rootfs",
|
||||
MountPath: "/rootfs/oem",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func pushImageName(artifact *osbuilder.OSArtifact) string {
|
||||
pushName := artifact.Spec.ImageName
|
||||
if pushName != "" {
|
||||
@ -138,7 +153,7 @@ func (r *OSArtifactReconciler) newArtifactPVC(artifact *osbuilder.OSArtifact) *c
|
||||
},
|
||||
Resources: corev1.ResourceRequirements{
|
||||
Requests: map[corev1.ResourceName]resource.Quantity{
|
||||
"storage": resource.MustParse("10Gi"),
|
||||
"storage": resource.MustParse("20Gi"),
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -202,7 +217,10 @@ func (r *OSArtifactReconciler) newBuilderPod(pvcName string, artifact *osbuilder
|
||||
)
|
||||
}
|
||||
if artifact.Spec.Model != nil {
|
||||
cmd = fmt.Sprintf("/build-arm-image.sh --model %s --state-partition-size 6200 --recovery-partition-size 4200 --size 15200 --images-size 2000 --config /iso/iso-overlay/cloud_config.yaml --docker-image %s /artifacts/%s.iso", *artifact.Spec.Model, artifact.Spec.ImageName, artifact.Name)
|
||||
cmd = fmt.Sprintf("/build-arm-image.sh --model %s --directory %s /artifacts/%s.iso", *artifact.Spec.Model, "/rootfs", artifact.Name)
|
||||
if artifact.Spec.CloudConfigRef != nil {
|
||||
cmd = fmt.Sprintf("/build-arm-image.sh --model %s --config /iso/iso-overlay/cloud_config.yaml --directory %s /artifacts/%s.iso", *artifact.Spec.Model, "/rootfs", artifact.Name)
|
||||
}
|
||||
}
|
||||
|
||||
buildIsoContainer := corev1.Container{
|
||||
@ -412,7 +430,17 @@ func (r *OSArtifactReconciler) newBuilderPod(pvcName string, artifact *osbuilder
|
||||
|
||||
if artifact.Spec.ISO && artifact.Spec.Model != nil {
|
||||
podSpec.InitContainers = []corev1.Container{}
|
||||
i := 0
|
||||
for name, bundle := range artifact.Spec.FileBundles {
|
||||
i++
|
||||
podSpec.InitContainers = append(podSpec.InitContainers, unpackFileContainer(fmt.Sprint(i), bundle, name))
|
||||
}
|
||||
for i, bundle := range artifact.Spec.Bundles {
|
||||
podSpec.InitContainers = append(podSpec.InitContainers, unpackContainer(fmt.Sprint(i), r.ToolImage, bundle))
|
||||
}
|
||||
podSpec.InitContainers = append(podSpec.InitContainers, unpackContainer("baseimage", r.ToolImage, artifact.Spec.ImageName))
|
||||
podSpec.Containers = make([]corev1.Container, 0)
|
||||
|
||||
podSpec.Containers = append(podSpec.Containers, buildIsoContainer)
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,7 @@ func (r *OSArtifactReconciler) Reconcile(ctx context.Context, req ctrl.Request)
|
||||
// CreateConfigMap generates a configmap required for building a custom image
|
||||
func (r *OSArtifactReconciler) CreateConfigMap(ctx context.Context, artifact *osbuilder.OSArtifact) error {
|
||||
cm := r.genConfigMap(artifact)
|
||||
|
||||
if cm.Labels == nil {
|
||||
cm.Labels = map[string]string{}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user