Image build
The combination of rp-cli and the local builder allows the user to build custom redpesk-os images. This allow him to add its custom application inside a generic redpesk-os image. In order to build an image locally, the user first needs to create an image object inside the redpesk backend, thanks to the rp-cli images add command.
Creating a new image
In order to build an image, the first step is to create an image object inside the redpesk backend 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-Devel -v 1 --security smack \
--ksurl "https://github.com/redpesk-infra/rp-kickstarts.git?.#arz-1.0" \
--kickstart "Redpesk-minimal-x86_64-smack.ks" \
-r "https://download.redpesk.bzh/redpesk-lts/arz-1.0-update/packages/middleware/x86_64/os/" \
-r "https://download.redpesk.bzh/redpesk-lts/arz-1.0/packages/middleware/x86_64/os/" \
-r "https://download.redpesk.bzh/redpesk-lts/arz-1.0-update/packages/baseos/x86_64/os/" \
-r "https://download.redpesk.bzh/redpesk-lts/arz-1.0/packages/baseos/x86_64/os/"
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.0 (commit_checkout)
Commit checkout arz-1.0 is set as a RefType.BRANCH ref
Trying shallow clone source from https://github.com/redpesk-infra/rp-kickstarts:arz-1.0 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