You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
5.0 KiB
5.0 KiB
Local development
Create a RHEL 9 Virtual Machine to play with os-builder and microshift
Pre-requisites :
- Fedora 39 with Libvirt installed
Download RHEL 9.3 and save rhel-9.3-x86_64-kvm.qcow2 in /var/lib/libvirt/images/base-images.
Create a file named user-data.yaml with the follwing content.
#cloud-config
users:
- name: nmasse
gecos: Nicolas MASSE
groups: wheel
lock_passwd: false
passwd: $6$...123 # generate the hash with the "mkpasswd" command
ssh_authorized_keys:
- ssh-ed25519 123...456
write_files:
- path: /etc/sudoers
content: |
Defaults !visiblepw
Defaults always_set_home
Defaults match_group_by_gid
Defaults always_query_group_plugin
Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS"
Defaults env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
root ALL=(ALL) ALL
%wheel ALL=(ALL) NOPASSWD: ALL
#includedir /etc/sudoers.d
permissions: '0440'
append: false
Create the RHEL9 VM.
sudo mkdir -p /var/lib/libvirt/images/rhel9 /var/lib/libvirt/images/base-images
sudo dnf install -y cloud-utils genisoimage
sudo cloud-localds /var/lib/libvirt/images/rhel9/cloud-init.iso user-data.yaml
sudo virt-install --name rhel9 --autostart --noautoconsole --cpu host-passthrough \
--vcpus 4 --ram 8192 --os-variant rhel9.3 \
--disk path=/var/lib/libvirt/images/rhel9/rhel9.qcow2,backing_store=/var/lib/libvirt/images/base-images/rhel-9.3-x86_64-kvm.qcow2,size=100 \
--disk path=/var/lib/libvirt/images/rhel9/data.qcow2,size=20 \
--network network=default \
--console pty,target.type=virtio --serial pty --import \
--disk path=/var/lib/libvirt/images/rhel9/cloud-init.iso,readonly=on \
--sysinfo system.serial=ds=nocloud
sudo virsh console rhel9
Create a PV and a VG for Microshift.
sudo pvcreate /dev/vdb
sudo vgcreate data /dev/vdb
Utility script that creates a VM to install RHEL for Edge
#!/bin/bash
set -Eeuo pipefail
DOMAIN="kiosk"
BASE_IMAGE_URL="your-user@rhel9-vm:red-hat-kiosk/imagebuilder/kiosk.iso"
BASE_IMAGE_FILENAME="$(basename "$BASE_IMAGE_URL")"
OS_VARIANT="rhel9.3"
virsh destroy "$DOMAIN" || true
virsh undefine "$DOMAIN" --nvram || true
rm -rf "/var/lib/libvirt/images/$DOMAIN/"
mkdir -p "/var/lib/libvirt/images/$DOMAIN"
scp "$BASE_IMAGE_URL" "/var/lib/libvirt/images/$DOMAIN/install.iso"
virt-install --name "$DOMAIN" --autostart --cpu host-passthrough \
--vcpus 2 --ram 4096 --os-variant "$OS_VARIANT" \
--disk "path=/var/lib/libvirt/images/$DOMAIN/os.qcow2,size=20" \
--disk "path=/var/lib/libvirt/images/$DOMAIN/data.qcow2,size=100" \
--network network=default \
--console pty,target.type=virtio --serial pty \
--cdrom "/var/lib/libvirt/images/$DOMAIN/install.iso" \
--boot uefi
Use it like follow :
eval $(ssh-agent)
ssh-add
sudo --preserve-env=SSH_AUTH_SOCK ./kiosk.sh
Use Microshift
export KUBECONFIG=/var/lib/microshift/resources/kubeadmin/kubeconfig
oc get nodes
Embed the ostree in the ISO
Create the ostree image.
composer-cli blueprints depsolve kiosk
BUILDID=$(composer-cli compose start-ostree --ref "rhel/9/$(uname -m)/edge" kiosk edge-container | awk '{print $2}')
echo "Build $BUILDID is running..."
wait_for_compose "$BUILDID"
Download the ostree server and run it.
CONTAINER_IMAGE_FILE="$(composer-cli compose image "${BUILDID}")"
IMAGEID="$(podman load < "${BUILDID}-container.tar" | grep -o -P '(?<=sha256[@:])[a-z0-9]*')"
echo "Using image with id = $IMAGEID"
podman stop -i minimal-microshift-server
podman rm -i minimal-microshift-server
podman run -d --rm --name=minimal-microshift-server -p 8085:8080 ${IMAGEID}
When building the ISO :
composer-cli blueprints push /dev/fd/0 <<EOF
name = "microshift-installer"
description = ""
version = "0.0.0"
modules = []
groups = []
packages = []
EOF
BUILDID=$(composer-cli compose start-ostree --url http://localhost:8085/repo/ --ref "rhel/9/$(uname -m)/edge" microshift-installer edge-installer | awk '{print $2}')
wait_for_compose "$BUILDID"
composer-cli compose image "${BUILDID}"
In the Kickstart script :
ostreesetup --nogpg --osname=rhel --remote=edge --url=file:///run/install/repo/ostree/repo --ref=rhel/9/x86_64/edge
Reclaim disk space
composer-cli compose list | awk 'NR > 1 { print $1 }' | xargs -n1 composer-cli compose delete
rm -f $GIT_REPO_CLONE/imagebuilder/*.{iso,tar}