@@ -337,6 +337,119 @@ watch sudo oc get pods -A \
337
337
--kubeconfig /var/lib/microshift/resources/kubeadmin/kubeconfig
338
338
```
339
339
340
+ ## Using Bootc Image Builder (BIB)
341
+
342
+ The [ bootc-image-builder] ( https://github.com/osbuild/bootc-image-builder ) , is a containerized tool to
343
+ create disk images from bootc images. You can use the images that you build to deploy disk images in
344
+ different environments, such as the edge, server, and clouds.
345
+
346
+ ### Prepare Build Config File
347
+ A build config is a Toml (or JSON) file with customizations for the resulting image.
348
+ The config file is mapped into the container directory to /config.toml. The customizations are
349
+ specified under a customizations object.
350
+
351
+ Set variables pointing to secret files that are included in ` config.toml ` for
352
+ gaining access to private container registries:
353
+ * ` PULL_SECRET ` file contents are copied to ` /etc/crio/openshift-pull-secret `
354
+ at the post-install stage to authenticate OpenShift registry access
355
+
356
+ ``` bash
357
+ PULL_SECRET=~ /.pull-secret.json
358
+ IMAGE_NAME=microshift-4.17-bootc
359
+ ```
360
+
361
+ Run the following command to create the ` kickstart.ks ` file to be used during
362
+ the virtual machine installation. If you want to embed the kickstart file directly
363
+ to iso using BIB please refer to [ upstream docs] ( https://osbuild.org/docs/bootc/#anaconda-iso-installer-options-installer-mapping )
364
+
365
+ ``` bash
366
+ cat > kickstart.ks << EOFKS
367
+ lang en_US.UTF-8
368
+ keyboard us
369
+ timezone UTC
370
+ text
371
+ reboot
372
+
373
+ # Partition the disk with hardware-specific boot and swap partitions, adding an
374
+ # LVM volume that contains a 10GB+ system root. The remainder of the volume will
375
+ # be used by the CSI driver for storing data.
376
+ zerombr
377
+ clearpart --all --initlabel
378
+ # Create boot and swap partitions as required by the current hardware platform
379
+ reqpart --add-boot
380
+ # Add an LVM volume group and allocate a system root logical volume
381
+ part pv.01 --grow
382
+ volgroup rhel pv.01
383
+ logvol / --vgname=rhel --fstype=xfs --size=10240 --name=root
384
+
385
+ # Lock root user account
386
+ rootpw --lock
387
+
388
+ # Configure network to use DHCP and activate on boot
389
+ network --bootproto=dhcp --device=link --activate --onboot=on
390
+
391
+ %post --log=/dev/console --erroronfail
392
+
393
+ # Create an OpenShift pull secret file
394
+ cat > /etc/crio/openshift-pull-secret <<'EOF'
395
+ $( cat " ${PULL_SECRET} " )
396
+ EOF
397
+ chmod 600 /etc/crio/openshift-pull-secret
398
+
399
+ %end
400
+ EOFKS
401
+ ```
402
+
403
+ ### Create ISO image using BIB
404
+
405
+ ``` bash
406
+ mkdir ./output
407
+
408
+ sudo podman run --authfile ${PULL_SECRET} --rm -it \
409
+ --privileged \
410
+ --security-opt label=type:unconfined_t \
411
+ -v /var/lib/containers/storage:/var/lib/containers/storage \
412
+ -v ./config.toml:/config.toml:ro \
413
+ -v ./output:/output \
414
+ registry.redhat.io/rhel9/bootc-image-builder:latest \
415
+ --local \
416
+ --type iso \
417
+ --config /config.toml \
418
+ localhost/${IMAGE_NAME} :latest
419
+ ```
420
+
421
+ ### Create Virtual Machine
422
+
423
+ Copy the ` install.iso ` file to the ` /var/lib/libvirt/images ` directory.
424
+
425
+ ``` bash
426
+ VMNAME=microshift-4.17-bootc
427
+ NETNAME=default
428
+
429
+ sudo cp -Z ./output/bootiso/install.iso /var/lib/libvirt/images/${VMNAME} .iso
430
+
431
+ sudo virt-install \
432
+ --name ${VMNAME} \
433
+ --vcpus 2 \
434
+ --memory 2048 \
435
+ --disk path=/var/lib/libvirt/images/${VMNAME} .qcow2,size=20 \
436
+ --network network=${NETNAME} ,model=virtio \
437
+ --events on_reboot=restart \
438
+ --location /var/lib/libvirt/images/${VMNAME} .iso \
439
+ --initrd-inject kickstart.ks \
440
+ --extra-args " inst.ks=file://kickstart.ks" \
441
+ --wait
442
+ ```
443
+
444
+ Log into the virtual machine using the ` redhat:<password> ` credentials.
445
+ Run the following command to verify that all the MicroShift pods are up and running
446
+ without errors.
447
+
448
+ ``` bash
449
+ watch sudo oc get pods -A \
450
+ --kubeconfig /var/lib/microshift/resources/kubeadmin/kubeconfig
451
+ ```
452
+
340
453
## Appendix A: Multi-Architecture Image Build
341
454
342
455
It is often convenient to build multi-architecture container images and store
0 commit comments