Skip to content

Instantly share code, notes, and snippets.

@agracey
Created September 21, 2022 00:30
Show Gist options
  • Save agracey/b0eedb7eef7094558197f94a7689f238 to your computer and use it in GitHub Desktop.
Save agracey/b0eedb7eef7094558197f94a7689f238 to your computer and use it in GitHub Desktop.
apiVersion: v1
data:
grub.cfg: |-
search --file --set=root /boot/kernel.xz
# Load custom config file
set custom="/boot/grub2/elementalversion"
search --no-floppy --file --set=custom_blk "${custom}"
if [ "${custom_blk}" ] ; then
load_env -f "(${custom_blk})${custom}"
fi
set default=0
set timeout=10
set timeout_style=menu
set linux=linux
set initrd=initrd
if [ "${grub_cpu}" = "x86_64" -o "${grub_cpu}" = "i386" -o "${grub_cpu}" = "arm64" ];then
if [ "${grub_platform}" = "efi" ]; then
if [ "${grub_cpu}" != "arm64" ]; then
set linux=linuxefi
set initrd=initrdefi
fi
fi
fi
if [ "${grub_platform}" = "efi" ]; then
echo "Please press 't' to show the boot menu on this console"
fi
set font=($root)/boot/${grub_cpu}/loader/grub2/fonts/unicode.pf2
if [ -f ${font} ];then
loadfont ${font}
fi
menuentry "Elemental Teal Install ${version}" --class os --unrestricted {
echo Loading kernel...
$linux ($root)/boot/kernel.xz cdroot root=live:CDLABEL=COS_LIVE rd.live.dir=/ rd.live.squashimg=rootfs.squashfs console=tty1 console=ttyS0 rd.cos.disable
echo Loading initrd...
$initrd ($root)/boot/rootfs.xz
}
if [ "${grub_platform}" = "efi" ]; then
hiddenentry "Text mode" --hotkey "t" {
set textmode=true
terminal_output console
}
fi
kind: ConfigMap
metadata:
name: elemental-build-config
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: build-host-iso
spec:
selector:
matchLabels:
app: build-host-iso
replicas: 1
template:
metadata:
labels:
app: build-host-iso
workload.user.cattle.io/workloadselector: apps.deployment-default-build-host-iso
spec:
initContainers:
- name: pull-registrations
image: rancher/shell:v0.1.18
workingDir: /mnt/yaml/
volumeMounts:
- name: yaml
mountPath: /mnt/yaml/
command: ["bash"]
args:
- -c
- |
URLS=`kubectl get machineregistrations -nfleet-default -ojson |jq -r ".items[].status.registrationURL"`
for u in $URLS
do
wget $u
done
- name: build-iso
image: registry.opensuse.org/isv/rancher/elemental/teal52/15.3/rancher/elemental-builder-image:latest
volumeMounts:
- name: public
mountPath: /mnt/public/
- name: tmp
mountPath: /tmp/
- name: config
mountPath: /iso/overlay/boot/grub2/grub.cfg
subPath: grub.cfg
- name: config
mountPath: /iso/overlay/livecd-cloud-config.yaml
subPath: config
- name: yaml
mountPath: /mnt/yaml/
workingDir: /iso/
command: ["bash"]
args:
- -c
- |
for reg in `ls /mnt/yaml/`
do
cp /mnt/yaml/$reg /iso/overlay/livecd-cloud-config.yaml
elemental build-iso -o /mnt/public --squash-no-compression -n $reg--overlay-iso overlay oci:registry.opensuse.org/isv/rancher/elemental/teal52/15.3/rancher/elemental-node-image/5.2:29.2
done
containers:
- name: host
image: nginx
ports:
- containerPort: 80
volumeMounts:
- name: public
mountPath: /usr/share/nginx/html
volumes:
- name: public
emptyDir: {}
- name: yaml
emptyDir: {}
- name: tmp
emptyDir: {}
- name: config
configMap:
name: elemental-build-config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment