Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 16. Creating and managing OSTree image updates
You can easily create and manage OStree image updates for your RHEL for Edge systems and make them immediately available to RHEL for Edge devices. With OSTree, you can use image builder to create RHEL for Edge Commit or RHEL for Edge Container images as .tar files that contain OSTree commits. The OSTree update versioning system works as a “Git repository" that stores and versions the OSTree commits. The rpm-ostree image and package system then assembles the commits on the client device. When you create a new image with RHEL image builder to perform an update, RHEL image builder pulls updates from these repositories.
16.1. Basic concepts for OSTree Copier lienLien copié sur presse-papiers!
Basic terms that OSTree and rpm-ostree use during image updates.
rpm-ostree-
The technology on the edge device that handles how the OSTree commits are assembled on the device. It works as a hybrid between an image and a package system. With the
rpm-ostreetechnology, you can make atomic upgrades and rollbacks to your system. - OSTree
- OSTree is a technology that enables you to create commits and download bootable file system trees. You can also use it to deploy the trees and manage the boot loader configuration.
- Commit
- An OSTree commit contains a full operating system that is not directly bootable. To boot the system, you must deploy it, for example, with a RHEL Installable image.
- Reference
It is also known as
ref. An OSTree ref is similar to a Git branch and it is a name. The following reference names examples are valid:-
rhel/9/x86_64/edge -
ref-name -
app/org.gnome.Calculator/x86_64/stable -
ref-name-2
-
By default, image builder specifies rhel/9/$ARCH/edge as a path. The "$ARCH" value is determined by the host machine.
- Parent
-
The
parentargument is an OSTree commit that you can provide to build a new commit with image builder. You can use theparentargument to specify an existingrefthat retrieves a parent commit for the new commit that you are building. You must specify the parent commit as a ref value to be resolved and pulled, for examplerhel/9/x86_64/edge. You can use the--parentcommit for the RHEL for Edge Commit (.tar) and RHEL for Edge Container (.tar) image types. - Remote
- The http or https endpoint that hosts the OSTree content. This is analogous to the baseurl for a yum repository.
- Static delta
- Static deltas are a collection of updates generated between two OSTree commits. This enables the system client to fetch a smaller amount of files, which are larger in size. The static deltas updates are more network efficient because, when updating an ostree-based host, the system client will only fetch the objects from the new OSTree commit which do not exist on the system. Typically, the new OSTree commit contains many small files, which requires multiple TCP connections.
- Summary
- The summary file is a concise way of enumerating refs, checksums, and available static deltas in an OSTree repo. You can check the state of all the refs and static deltas available in an Ostree repo. However, you must generate the summary file every time a new ref, commit, or static-delta is added to the OSTree repo.
16.2. Creating OSTree repositories Copier lienLien copié sur presse-papiers!
You can create OSTree repos with RHEL image builder by using either RHEL for Edge Commit (.tar) or RHEL for Edge Container (.tar) image types. These image types contain an OSTree repo that contains a single OSTree commit.
-
You can extract the
RHEL for Edge Commit (.tar)on a web server and it is ready to be served. -
You must import the
RHEL for Edge Container (.tar)to a local container image storage or push the image to a container registry. After you start the container, it serves the commit over an integratednginxweb server.
Use the RHEL for Edge Container (.tar) on a RHEL server with Podman to create an OSTree repo:
Prerequisites
-
You created a
RHEL for Edge Container (.tar)image.
Procedure
Download the container image from image builder:
composer-cli compose image _<UUID>
$ composer-cli compose image _<UUID>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Import the container into Podman:
skopeo copy oci-archive:_<UUID>_-container.tar containers-storage:localhost/ostree
$ skopeo copy oci-archive:_<UUID>_-container.tar containers-storage:localhost/ostreeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start the container and make it available by using the port
8080:podman run -rm -p 8080:8080 ostree
$ podman run -rm -p 8080:8080 ostreeCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Check that the container is running:
podman ps -a
$ podman ps -aCopy to Clipboard Copied! Toggle word wrap Toggle overflow
16.3. Managing a centralized OSTree mirror Copier lienLien copié sur presse-papiers!
For production environments, having a central OSTree mirror that serves all the commits has several advantages, including:
- Deduplicating and minimizing disk storage
- Optimizing the updates to clients by using static delta updates
- Pointing to a single OSTree mirror for their deployment life.
To manage a centralized OSTree mirror, you must pull each commit from image builder into the centralized repository where it will be available to your users.
You can also automate managing an OSTree mirror by using the infra.osbuild Ansible collection. See osbuild.infra Ansible.
To create a centralized repository you can run the following commands directly on a web server:
Procedure
Create an empty blueprint, customizing it to use "rhel-92" as the distro:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Push the blueprint to the server:
composer-cli blueprints push minimal-rhel92.toml
# composer-cli blueprints push minimal-rhel92.tomlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Build a RHEL for Edge Commit (
.tar) image from the blueprint you created:composer-cli compose start-ostree minimal-rhel92 edge-commit
# composer-cli compose start-ostree minimal-rhel92 edge-commitCopy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the
.tar fileand decompress it to the disk:composer-cli compose image _<rhel-92-uuid> tar -xf <rhel-92-uuid>.tar -C /usr/share/nginx/html/
# composer-cli compose image _<rhel-92-uuid> $ tar -xf <rhel-92-uuid>.tar -C /usr/share/nginx/html/Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
/usr/share/nginx/html/repolocation on disk will become the single OSTree repo for all refs and commits.Create another empty blueprint, customizing it to use "rhel-87" as the distro:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Push the blueprint and create another RHEL for Edge Commit (
.tar) image:composer-cli blueprints push minimal-rhel87.toml composer-cli compose start-ostree minimal-rhel87 edge-commit
# composer-cli blueprints push minimal-rhel87.toml # composer-cli compose start-ostree minimal-rhel87 edge-commitCopy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the
.tar fileand decompress it to the disk:composer-cli compose image <rhel-87-uuid> tar -xf <rhel-87-uuid>.tar
# composer-cli compose image <rhel-87-uuid> $ tar -xf <rhel-87-uuid>.tarCopy to Clipboard Copied! Toggle word wrap Toggle overflow Pull the commit to the local repo. By using
ostree pull-local, you can copy the commit data from one local repo to another local repo.ostree --repo=/usr/share/nginx/html/repo pull-local repo
# ostree --repo=/usr/share/nginx/html/repo pull-local repoCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Inspect the status of the OSTree repo. The following is an output example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the RHEL 9.2 blueprint to include a new package and build a new commit, for example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Push the updated blueprint and create a new RHEL for Edge Commit (
.tar) image, pointing the compose to the existing OSTree repo:composer-cli blueprints push minimal-rhel92.toml composer-cli compose start-ostree minimal-rhel92 edge-commit --url http://localhost/repo --ref rhel/9/x86_64/edge
# composer-cli blueprints push minimal-rhel92.toml # composer-cli compose start-ostree minimal-rhel92 edge-commit --url http://localhost/repo --ref rhel/9/x86_64/edgeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the
.tarfile and decompress it to the disk:rm -rf repo composer-cli compose image <rhel-92-uuid> tar -xf <rhel-92-uuid>.tar
# rm -rf repo # composer-cli compose image <rhel-92-uuid> # tar -xf <rhel-92-uuid>.tarCopy to Clipboard Copied! Toggle word wrap Toggle overflow Pull the commit to repo:
ostree --repo=/usr/share/nginx/html/repo pull-local repo
# ostree --repo=/usr/share/nginx/html/repo pull-local repoCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Inspect the OSTree repo status again:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.4. Performing updates by using static deltas Copier lienLien copié sur presse-papiers!
You can use static deltas to improve the speed of your client repository updates. If static deltas for an update exist, they are used. If not, the update still happens, but with a lower speed.
After building an OSTree system, if you want to retrieve the content from your client systems, you need to create a repository management.
By default, the repository you use for production requires one HTTP fetch transaction per client request. If you perform releases only once a week, use “static deltas" to get client repository updates faster.
Prerequisites
-
You have a RHEL
reporepository running with Podman. - You have created a centralized OSTree mirror to use as the production repository.
Procedure
Pull the content update from the
reporepository into therepo-prodrepository:ostree --repo=/usr/share/nginx/html/repo pull-local repo-prod
# ostree --repo=/usr/share/nginx/html/repo pull-local repo-prodCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf you do not specify the
refsbranch, theostree-pull-localcommand retrieves all the branches. As an alternative to theostree-pull-localcommand, you can also use theostree-pullcommand. The difference is thatostree-pull-localis optimized for copies only between repositories on the same system, whileostree-pullcan download data from a remote repository.Apply a delta update against the previous commit. The static generation happens on the local repository, in this case,
prod. After the delta update is generated, the update is done offline.NoteYou must have at least two commits in the repository where you want to generate static deltas.
ostree --repo=/usr/share/nginx/html/client-server static-delta generate exampleos/x86_64/standard
# ostree --repo=/usr/share/nginx/html/client-server static-delta generate exampleos/x86_64/standardCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: If you want to upgrade from the two previous commits, run the following command:
ostree --repo=repo-prod static-delta generate --from=exampleos/x86_64/standard^^ --to=exampleos/x86_64/standard
# ostree --repo=repo-prod static-delta generate --from=exampleos/x86_64/standard^^ --to=exampleos/x86_64/standardCopy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantGenerating a full permutation of deltas across all previous versions can be a heavy workload for your systems. The OSTree core has some support for static deltas which refer to a parent.
Update the summary file:
ostree --repo=repo-prod summary -u
# ostree --repo=repo-prod summary -uCopy to Clipboard Copied! Toggle word wrap Toggle overflow You need to update the summary file, even if you choose to generate static deltas. The summary command cannot run concurrently. It must be triggered serially by other jobs. That is, you must generate a summary file after generating the static-deltas, because the previous command added a new static delta.
Use the generated static delta to apply to the existing Operating System and perform updates:
ostree --repo=/ostree/repo-prod static-delta <delta-update-file-path>
# ostree --repo=/ostree/repo-prod static-delta <delta-update-file-path>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the OSTree delta update:
sudo rpm-ostree upgrade
$ sudo rpm-ostree upgradeCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot into the new image to apply the updates:
systemctl reboot
$ systemctl rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow