Image build
Image build within local builder is not available with Community edition.
See Community edition chapter for more information.
The combination of rp-cli
and the local builder allows the user to build custom redpesk images.
In order to build an image locally, the user first needs to create a parent project.
Inside this project an image object can be created, thanks to the rp-cli images add
command.
Creating a new project
# Creation of the parent project, supporting image type
$ rp-cli projects add -n "Custom Image project" -a "custom-image-project" --mandatory-distro redpesk-lts-arz-1.1-update --mandatory-arch x86_64 --optional-arch aarch64 --images
-- Project creation requested by user --
Checking that at least one architecture is set... [OK]
Checking that at least one distribution is set... [OK]
Creation of "Custom Image project" project... [OK]
Creating a new image
Once that a parent project has been created, you can proceed with the image creation thanks to the rp-cli images add
command.
Use --help
to explore available options and sub-commands of rp-cli images add
.
rp-cli images add --help
Here is an example to create a x86_64 redpesk-os image:
rp-cli images add -n "My beautiful image" --arch x86_64 -d redpesk-lts-arz-1.1-update --security smack -p custom-image-project \
--ks-url "https://github.com/redpesk-infra/rp-kickstarts.git" \
--ks-branch "arz-1.1-update" \
--ks-path "." \
--ks-file "Redpesk-minimal-x86_64-smack.ks"
WARNING: Note that all repo must respect the configured image architecture otherwise, image will not build.
Building an image
Once the image object added inside the redpesk backend, rp-cli is ready to launch the build of the image. To have more information, you can consult help:
rp-cli images localbuild --help
Let’s see with our example:
rp-cli images localbuild my-beautiful-image
The build is now launched, just wait for the build to be completed.
-- Local build of an image requested by user --
Checking that all needed parameters are set... [OK]
Checking and preparing the directory for image build... [OK]
"Image build" directory set-up: /home/devel/sandbox/gitpkgs/image_localbuild_my-beautiful-image
IMAGE BUILD LOGS >>>
kickstart = Redpesk-core-x86_64-smack.ks
Will try to checkout to arz-1.1-update (commit_checkout)
Commit checkout arz-1.1-update is set as a RefType.BRANCH ref
Trying shallow clone source from https://github.com/redpesk-infra/rp-kickstarts:arz-1.1-update into /tmp/tmp1ega1jyl/gitsource
Successfull shallow cloned.
Preparing the kickstart
Writing kickstart in temporary dir /tmp/tmp1ega1jyl/Redpesk-core-x86_64-smack.ks
Writing TDL in temporary dir /tmp/tmp1ega1jyl/tdl-x86_64.xml
Building image
DEBUG:oz.Guest.RedPeskGuest:libvirt bridge name is virbr0
DEBUG:oz.Guest.RedPeskGuest:Libvirt type is kvm
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): download.redpesk.bzh:443
[..]
DEBUG:oz.ozutil:Waiting for my-beautiful-image to finish installing, 99630/100000
DEBUG:oz.ozutil:Waiting for my-beautiful-image to finish shutdown, 90/90
INFO:oz.Guest.RedPeskGuest:Install of my-beautiful-image succeeded
INFO:oz.Guest.RedPeskGuest:Generate XML for guest my-beautiful-image with bootdev hd
DEBUG:oz.Guest.RedPeskGuest:Generated XML:
<domain type="kvm">
<name>my-beautiful-image</name>
<memory>4194304</memory>
<currentMemory>4194304</currentMemory>
<uuid>522a07d7-5ab5-42af-94b9-c4d8257e971c</uuid>
<clock offset="utc"/>
<vcpu>4</vcpu>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<os>
<type machine="q35">hvm</type>
<boot dev="hd"/>
<loader readonly="yes" type="pflash">/usr/share/OVMF/OVMF_CODE.secboot.fd</loader>
<nvram template="/usr/share/OVMF/OVMF_VARS.secboot.fd"/>
</os>
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<graphics port="-1" type="vnc"/>
<interface type="bridge">
<source bridge="virbr0"/>
<mac address="52:54:00:87:55:ef"/>
<model type="virtio"/>
</interface>
<input bus="ps2" type="mouse"/>
<serial type="pty">
<target port="0"/>
</serial>
<serial type="tcp">
<source mode="bind" host="127.0.0.1" service="50791"/>
<protocol type="raw"/>
<target port="1"/>
</serial>
<rng model="virtio">
<rate bytes="1024" period="1000"/>
<backend model="random">/dev/random</backend>
</rng>
<disk device="disk" type="file">
<target dev="vda" bus="virtio"/>
<source file="/home/devel/.oz/images/my-beautiful-image.dsk"/>
<driver name="qemu" type="raw"/>
</disk>
</devices>
</domain>
INFO:oz.Guest.RedPeskGuest:Cleaning up after install
Libvirt XML was written to my-beautiful-imageAug_23_2021-15:25:37
Compressing image
Removing the image and workdir.
<<< IMAGE BUILD LOGS
Congratulations! Your image build seems to be successful!
Image available in: /home/devel/sandbox/gitpkgs/image_localbuild_my-beautiful-image