هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
الهدف
Build a bootable container image with Apache, turn it into a KVM disk, boot a VM from it, then ship version 2 as an update — and roll it back.
قبل أن تبدأ
- A RHEL 10 machine with KVM (
virt-install) and at least 20 GiB free disk, registered, with access toregistry.redhat.io(podman login registry.redhat.io). - A registry the VM can pull from. The easiest is a free account on
quay.io(make the repository public), or a local registry on server1. sudo dnf install -y container-tools virt-install.- In the tasks, replace
quay.io/YOURNAMEwith your own registry path.
المهام
ضع علامة على المهمة عندما تنتهي منها. متصفحك فقط يتذكر ذلك.
- Write a Containerfile that starts from
registry.redhat.io/rhel10/rhel-bootc:10.0, installshttpd, enables it, opens nothing else, and serves a pageversion 1from/usr/share/web/html. - Build the image as
quay.io/YOURNAME/web-bootc:1.0, test thathttpdis in it, and push it. Also tag and push it as:prod. - Make a
qcow2disk with bootc-image-builder. Add a useradmininwheelwith your SSH key. - Boot a VM
bootc1from the disk. Log in asadminand check the image withbootc status. Make sure the VM follows the tag:prod. - Change the page to
version 2, build:2.0, and push it as:prod. Updatebootc1and reboot it. - Roll
bootc1back to version 1 and reboot again.
تحقّق من عملك
تلميحات
اعرض التلميحات
/varis not updated by new images. Put the web page in/usr/share/web/htmland point Apache there with a small config file in/etc/httpd/conf.d/.- bootc-image-builder runs as root and reads root's container storage:
sudo podman pullthe image first. - A VM made from the
:1.0disk follows:1.0.bootc switch quay.io/YOURNAME/web-bootc:prodmakes it follow:prod. - On the KVM host,
virsh domifaddr bootc1shows the address of the VM. The libvirt network lets the host reach port 80 of the VM.
الحل
اعرض الحل
- The build folder.
mkdir -p ~/web-bootc/html && cd ~/web-bootc echo "version 1" > html/index.html printf 'DocumentRoot "/usr/share/web/html"\n<Directory "/usr/share/web/html">\n Require all granted\n</Directory>\n' > web.conf cat Containerfile FROM registry.redhat.io/rhel10/rhel-bootc:10.0 RUN dnf -y install httpd && dnf clean all COPY web.conf /etc/httpd/conf.d/web.conf COPY html/ /usr/share/web/html/ RUN systemctl enable httpd - Build, test, push.
podman login registry.redhat.io podman login quay.io podman build -t quay.io/YOURNAME/web-bootc:1.0 . podman run --rm quay.io/YOURNAME/web-bootc:1.0 rpm -q httpd podman push quay.io/YOURNAME/web-bootc:1.0 podman tag quay.io/YOURNAME/web-bootc:1.0 quay.io/YOURNAME/web-bootc:prod podman push quay.io/YOURNAME/web-bootc:prod - The disk image (as root).
cat config.toml [[customizations.user]] name = "admin" key = "ssh-ed25519 AAAA...your-key" groups = ["wheel"] sudo podman pull quay.io/YOURNAME/web-bootc:prod mkdir -p output sudo podman run --rm -it --privileged --pull=newer --security-opt label=type:unconfined_t -v ./config.toml:/config.toml:ro -v ./output:/output -v /var/lib/containers/storage:/var/lib/containers/storage registry.redhat.io/rhel10/bootc-image-builder:latest --type qcow2 quay.io/YOURNAME/web-bootc:prod - Boot the VM and check it.
sudo cp output/qcow2/disk.qcow2 /var/lib/libvirt/images/bootc1.qcow2 sudo virt-install --name bootc1 --memory 2048 --vcpus 2 --import --disk /var/lib/libvirt/images/bootc1.qcow2 --os-variant rhel10.0 --graphics none --noautoconsole sudo virsh domifaddr bootc1 ssh admin@BOOTC1 'sudo bootc status' curl -s http://BOOTC1/ - Version 2 as an update.
echo "version 2" > html/index.html podman build -t quay.io/YOURNAME/web-bootc:2.0 . podman push quay.io/YOURNAME/web-bootc:2.0 podman tag quay.io/YOURNAME/web-bootc:2.0 quay.io/YOURNAME/web-bootc:prod podman push quay.io/YOURNAME/web-bootc:prod ssh admin@BOOTC1 'sudo bootc upgrade --apply' curl -s http://BOOTC1/ - Roll back.
ملاحظاتي
لا توجد ملاحظات بعد.