Skip to content

Commit 14f41e9

Browse files
Merge pull request #63911 from ShaunaDiaz/OSDOCS-4558
OSDOCS-4558: embedding apps for microshift
2 parents ecd9dfe + eba1932 commit 14f41e9

9 files changed

+412
-0
lines changed

_topic_maps/_topic_map_ms.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ Name: Running applications
157157
Dir: microshift_running_apps
158158
Distros: microshift
159159
Topics:
160+
- Name: Embedded applications on RHEL for Edge
161+
File: microshift-embedded-apps-on-rhel-edge
162+
- Name: Embedding applications for offline use
163+
File: microshift-embed-apps-offline-use
164+
- Name: Embedding applications tutorial
165+
File: microshift-embedding-apps-tutorial
160166
- Name: Application deployment
161167
File: microshift-applications
162168
- Name: Operators
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
:_content-type: ASSEMBLY
2+
[id="microshift-embed-apps-offline-use"]
3+
= Embedding {product-title} applications for offline use
4+
include::_attributes/attributes-microshift.adoc[]
5+
:context: microshift-embed-apps-offline-use
6+
7+
toc::[]
8+
9+
You can embed microservices-based workloads and applications in a {op-system-ostree-first} image. This allows users to run a {product-title} cluster in air-gapped, disconnected, or offline environment.
10+
11+
include::modules/microshift-embed-images-offline-use.adoc[leveloffset=+1]
12+
13+
//additional resources for embedding images for offline use
14+
[id="Additional-resources_microshift-embed-apps-offline-use_{context}"]
15+
[role="_additional-resources"]
16+
== Additional resources
17+
18+
* xref:../microshift_running_apps/microshift-embedded-apps-on-rhel-edge.adoc#microshift-embedded-apps-on-rhel-edge[Options for embedding {product-title} applications in a {op-system-ostree} image]
19+
20+
* xref:../microshift_install/microshift-embed-in-rpm-ostree.adoc#microshift-creating-ostree-iso_microshift-embed-in-rpm-ostree[Creating the {op-system-ostree} image]
21+
22+
* xref:../microshift_install/microshift-embed-in-rpm-ostree.adoc#microshift-add-blueprint-build-iso_microshift-embed-in-rpm-ostree[Add the blueprint to Image Builder and build the ISO]
23+
24+
* xref:../microshift_install/microshift-embed-in-rpm-ostree.adoc#microshift-download-iso-prep-for-use_microshift-embed-in-rpm-ostree[Download the ISO and prepare it for use]
25+
26+
* link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html-single/composing_installing_and_managing_rhel_for_edge_images/index#upgrading_rhel_for_edge_systems[Upgrading {op-system-ostree} systems]
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
:_content-type: ASSEMBLY
2+
[id="microshift-embedded-apps-on-rhel-edge"]
3+
= Options for embedding {product-title} applications in a {op-system-ostree} image
4+
include::_attributes/attributes-microshift.adoc[]
5+
:context: microshift-embedded-apps-on-rhel-edge
6+
7+
toc::[]
8+
9+
You can embed microservices-based workloads and applications in a {op-system-ostree-first} image to run in a {product-title} cluster. Embedded applications can be installed directly on edge devices to run in air-gapped, disconnected, or offline environments.
10+
11+
[id="microshift-add-app-RPMs-to-rpm-ostree-image_{context}"]
12+
== Adding application RPMs to an rpm-ostree image
13+
If you have an application that includes APIs, container images, and configuration files for deployment such as manifests, you can build application RPMs. You can then add the RPMs to your {op-system-ostree} system image.
14+
15+
The following is an outline of the procedures to embed applications or workloads in an fully self-contained operating system image:
16+
17+
* Build your own RPM that includes your application manifest.
18+
* Add the RPM to the blueprint you used to install {product-title}.
19+
* Add the workload container images to the same blueprint.
20+
* Create a bootable ISO.
21+
22+
For a step-by-step tutorial about preparing and embedding applications in a {op-system-ostree} image, use the following tutorial:
23+
24+
* xref:../microshift_running_apps/microshift-embedding-apps-tutorial.adoc#microshift-embedding-apps-tutorial[Embedding applications tutorial]
25+
26+
[id="microshift-add-app-manifests-to-image_{context}"]
27+
== Adding application manifests to an image for offline use
28+
If you have a simple application that includes a few files for deployment such as manifests, you can add those manifests directly to a {op-system-ostree} system image.
29+
30+
See the "Create a custom file blueprint customization" section of the following {op-system-ostree} documentation for an example:
31+
32+
* link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/composing_installing_and_managing_rhel_for_edge_images/composing-a-rhel-for-edge-image-using-image-builder-command-line_composing-installing-managing-rhel-for-edge-images#image-customizations_composing-a-rhel-for-edge-image-using-image-builder-command-line[Create a custom file blueprint customization]
33+
34+
[id="microshift-embed-apps-for-offline-use_{context}"]
35+
== Embedding applications for offline use
36+
If you have an application that includes more than a few files, you can embed the application for offline use. See the following procedure:
37+
38+
* xref:../microshift_running_apps/microshift-embed-apps-offline-use.adoc#microshift-embed-apps-offline-use[Embedding applications for offline use]
39+
40+
//additional resources for assembly
41+
[id="additional-resources_microshift-embed-apps-on-rhel-edge_{context}"]
42+
[role="_additional-resources"]
43+
== Additional resources
44+
* xref:../microshift_install/microshift-embed-in-rpm-ostree.adoc#microshift-embed-in-rpm-ostree[Embedding {product-title} in an RPM-OSTree image]
45+
46+
* link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/{op-system-version-major}/html/composing_installing_and_managing_rhel_for_edge_images/index[Composing, installing, and managing {op-system-ostree} images]
47+
48+
* xref:../microshift_install/microshift-embed-in-rpm-ostree.adoc#preparing-for-image-building_microshift-embed-in-rpm-ostree[Preparing for image building]
49+
50+
* link:https://cloud.redhat.com/blog/meet-red-hat-device-edge-with-microshift[Meet Red Hat Device Edge]
51+
52+
* link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/{op-system-version-major}/html-single/composing_installing_and_managing_rhel_for_edge_images/index#composing-a-rhel-for-edge-image-using-image-builder-command-line_composing-installing-managing-rhel-for-edge-images[Composing a RHEL for Edge image using image builder command-line]
53+
54+
* link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/{op-system-version-major}/html-single/composing_installing_and_managing_rhel_for_edge_images/index#edge-image-builder-system-requirements_setting-up-image-builder[Image Builder system requirements]
55+
56+
//* link:https://www.redhat.com/sysadmin/create-rpm-package[How to create a Linux RPM package]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
:_content-type: ASSEMBLY
2+
[id="microshift-embedding-apps-tutorial"]
3+
= Embedding {product-title} applications tutorial
4+
include::_attributes/attributes-microshift.adoc[]
5+
:context: microshift-embedding-apps-tutorial
6+
7+
toc::[]
8+
9+
The following tutorial gives a detailed example of how to embed applications in a {op-system-ostree} image for use in a {product-title} cluster in various environments.
10+
11+
include::modules/microshift-embed-app-rpms-tutorial.adoc[leveloffset=+1]
12+
13+
include::modules/microshift-preparing-to-make-app-rpms.adoc[leveloffset=+2]
14+
15+
include::modules/microshift-building-apps-rpms.adoc[leveloffset=+2]
16+
17+
include::modules/microshift-adding-app-rpms-to-blueprint.adoc[leveloffset=+2]
18+
19+
//additional resources for adding app rpms to blueprint
20+
[role="_additional-resources"]
21+
.Additional resources
22+
* link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/composing_installing_and_managing_rhel_for_edge_images/composing-a-rhel-for-edge-image-using-image-builder-command-line_composing-installing-managing-rhel-for-edge-images#doc-wrapper[Composing a {op-system-ostree} image using the Image Builder CLI]
23+
24+
* link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/composing_installing_and_managing_rhel_for_edge_images/composing-a-rhel-for-edge-image-using-image-builder-command-line_composing-installing-managing-rhel-for-edge-images#network_based_deployments_workflow[Network-based deployments workflow]
25+
26+
//additional resources for assembly
27+
[id="additional-resources_microshift-embedding-apps-tutorial_{context}"]
28+
[role="_additional-resources"]
29+
== Additional resources
30+
* xref:../microshift_running_apps/microshift-embed-apps-offline-use.adoc#microshift-embed-apps-offline-use[Embedding applications for offline use]
31+
32+
* xref:../microshift_install/microshift-embed-in-rpm-ostree.adoc#microshift-embed-in-rpm-ostree[Embedding {product-title} in an RPM-OSTree image]
33+
34+
* link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/{op-system-version-major}/html/composing_installing_and_managing_rhel_for_edge_images/index[Composing, installing, and managing {op-system-ostree} images]
35+
36+
* xref:../microshift_install/microshift-embed-in-rpm-ostree.adoc#preparing-for-image-building_microshift-embed-in-rpm-ostree[Preparing for image building]
37+
38+
* link:https://cloud.redhat.com/blog/meet-red-hat-device-edge-with-microshift[Meet Red Hat Device Edge with {product-title}]
39+
40+
* link:https://www.redhat.com/sysadmin/create-rpm-package[How to create a Linux RPM package]
41+
42+
* link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/{op-system-version-major}/html-single/composing_installing_and_managing_rhel_for_edge_images/index#composing-a-rhel-for-edge-image-using-image-builder-command-line_composing-installing-managing-rhel-for-edge-images[Composing a {op-system-ostree} image using image builder command-line]
43+
44+
* link:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/{op-system-version-major}/html-single/composing_installing_and_managing_rhel_for_edge_images/index#edge-image-builder-system-requirements_setting-up-image-builder[Image Builder system requirements]
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Module included in the following assemblies:
2+
//
3+
// microshift_running_applications/embedding-apps-tutorial.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="microshift-adding-app-rpms-to-blueprint_{context}"]
7+
= Adding application RPMs to a blueprint
8+
9+
To add application RPMs to a blueprint, you must create a local repository that Image Builder can use to create the ISO. With this procedure, the required container images for your workload can be pulled over the network.
10+
11+
.Prerequisites
12+
13+
* You have root access to the host.
14+
* Workload or application RPMs exist in the `~/rpmbuild/RPMS` directory.
15+
16+
.Procedure
17+
18+
. Create a local RPM repository by running the following command:
19+
+
20+
[source,terminal]
21+
----
22+
$ createrepo ~/rpmbuild/RPMS/
23+
----
24+
25+
. Give Image Builder access to the RPM repository by running the following command:
26+
+
27+
[source,terminal]
28+
----
29+
$ sudo chmod a+rx ~
30+
----
31+
+
32+
[NOTE]
33+
====
34+
You must ensure that Image Builder has all of the necessary permissions to access all of the files needed for image building, or the build cannot proceed.
35+
====
36+
+
37+
. Create the blueprint file, `repo-local-rpmbuild.toml` using the following template:
38+
+
39+
[source,toml]
40+
----
41+
id = "local-rpm-build"
42+
name = "RPMs build locally"
43+
type = "yum-baseurl"
44+
url = "file://<path>/rpmbuild/RPMS" <1>
45+
check_gpg = false
46+
check_ssl = false
47+
system = false
48+
----
49+
<1> Specify part of the path to create a location that you choose. Use this path in the later commands to set up the repository and copy the RPMs.
50+
51+
. Add the repository as a source for Image Builder by running the following command:
52+
+
53+
[source,terminal]
54+
----
55+
$ sudo composer-cli sources add repo-local-rpmbuild.toml
56+
----
57+
58+
. Add the RPM to your blueprint, by adding the following lines:
59+
+
60+
[source,toml]
61+
----
62+
63+
[[packages]]
64+
name = "<application_workload_manifests>" <1>
65+
version = "*"
66+
67+
----
68+
<1> Add the name of your workload here.
69+
70+
. Push the updated blueprint to Image Builder by running the following command:
71+
+
72+
[source,terminal]
73+
----
74+
$ sudo composer-cli blueprints push repo-local-rpmbuild.toml
75+
----
76+
77+
. At this point, you can either run Image Builder to create the ISO, or embed the container images for offline use.
78+
79+
.. To create the ISO, start Image Builder by running the following command:
80+
+
81+
[source,terminal]
82+
----
83+
$ sudo composer-cli compose start-ostree repo-local-rpmbuild edge-commit
84+
----
85+
86+
In this scenario, the container images are pulled over the network by the edge device during startup.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Module included in the following assemblies:
2+
//
3+
// microshift_running_applications/embedding-apps-tutorial.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="microshift-building-apps-rpms_{context}"]
7+
= Building the RPM package for the application manifests
8+
9+
To building your own RPMs, you must create a spec file that adds the application manifests to the RPM package. The following is an example procedure. As long as the application RPMs and other elements needed for image building are accessible to Image Builder, you can use the method that you prefer.
10+
11+
.Prerequisites
12+
* You have set up a {op-system-ostree-first} {op-system-version} build host that meets the Image Builder system requirements.
13+
* You have root access to the host.
14+
* The file tree required to build RPM packages was created.
15+
16+
.Procedure
17+
18+
. In the `~/rpmbuild/SPECS` directory, create a file such as `<application_workload_manifests.spec>` using the following template:
19+
+
20+
.Example `.spec` file
21+
[source,terminal]
22+
----
23+
Name: <application_workload_manifests>
24+
Version: 0.0.1
25+
Release: 1%{?dist}
26+
Summary: Adds workload manifests to microshift
27+
BuildArch: noarch
28+
License: GPL
29+
Source0: %{name}-%{version}.tar.gz
30+
#Requires: microshift
31+
%description
32+
Adds workload manifests to microshift
33+
%prep
34+
%autosetup
35+
%install <1>
36+
rm -rf $RPM_BUILD_ROOT
37+
mkdir -p $RPM_BUILD_ROOT/%{_prefix}/lib/microshift/manifests
38+
cp -pr ~/manifests $RPM_BUILD_ROOT/%{_prefix}/lib/microshift/
39+
%clean
40+
rm -rf $RPM_BUILD_ROOT
41+
42+
%files
43+
%{_prefix}/lib/microshift/manifests/**
44+
%changelog
45+
* <DDD MM DD YYYY username@domain - V major.minor.patch>
46+
- <your_change_log_comment>
47+
----
48+
<1> The `%install` section creates the target directory inside the RPM package, `/usr/lib/microshift/manifests/`
49+
and copies the manifests from the source home directory, `~/manifests`.
50+
+
51+
[IMPORTANT]
52+
====
53+
All of the required YAML files must be in the source home directory `~/manifests`, including a `kustomize.yaml` file if you are using kustomize.
54+
====
55+
56+
. Build your RPM package in the `~/rpmbuild/RPMS` directory by running the following command:
57+
+
58+
[source,terminal]
59+
----
60+
$ rpmbuild -bb ~/rpmbuild/SPECS/<application_workload_manifests.spec>
61+
----
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Module included in the following assemblies:
2+
//
3+
// microshift_running_applications/embedding-apps-tutorial.adoc
4+
5+
:_content-type: CONCEPT
6+
[id="microshift-embed-app-rpms-tutorial_{context}"]
7+
= Embed application RPMs tutorial
8+
9+
The following tutorial reviews the {product-title} installation steps and adds a description of the workflow for embedding applications. If you are already familiar with `rpm-ostree` systems such as {op-system-ostree-first} and {product-title}, you can go straight to the procedures.
10+
11+
[id="microshift-installation-workflow-review"]
12+
== Installation workflow review
13+
Embedding applications requires a similar workflow to embedding {product-title} into a {op-system-ostree} image. Reviewing those steps can help you understand the steps needed to embed an application:
14+
//larger concept image here
15+
16+
. To embed {product-title} on {op-system-ostree}, you added the {product-title} repositories to Image Builder.
17+
18+
. You created a blueprint that declared all the RPMs, container images, files and customizations you needed, including the addition of {product-title}.
19+
20+
. You added the blueprint to Image Builder and ran a build with the Image Builder CLI tool (`composer-cli`). This step created `rpm-ostree` commits, which were used to create the container image. This image contained {op-system-ostree}.
21+
22+
. You added the installer blueprint to Image Builder to create an `rpm-ostree` image (ISO) to boot from. This build contained both {op-system-ostree} and {product-title}.
23+
24+
. You downloaded the ISO with {product-title} embedded, prepared it for use, provisioned it, then installed it onto your edge devices.
25+
26+
[id="microshift-embed-app-rpms-workflow"]
27+
== Embed application RPMs workflow
28+
29+
After you have set up a build host that meets the Image Builder requirements, you can add your application in the form of a directory of manifests to the image. After those steps, the simplest way to embed your application or workload into a new ISO is to create your own RPMs that include the manifests. Your application RPMs contain all of the configuration files describing your deployment.
30+
31+
The following procedures use the `rpmbuild` tool to create a `.spec` file and local repository. The `.spec` file defines how the package is built, moving your application manifests to the correct location inside the RPM package for {product-title} to pick them up. That RPM package is then embedded in the ISO.
32+
33+
//rpm workflow image here
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Module included in the following assemblies:
2+
//
3+
// microshift_running_applications/embed-microshift-apps-on-rhel-edge.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="microshift-embed-images-offline-use_{context}"]
7+
= Embedding workload container images for offline use
8+
9+
To embed container images in devices at the edge that do not have any network connection, you must create a new container, mount the ISO, and then copy the contents into the file system.
10+
11+
.Prerequisites
12+
13+
* You have root access to the host.
14+
* Application RPMs have been added to a blueprint.
15+
16+
.Procedure
17+
18+
. Render the manifests, extract all of the container image references, and translate the application image to blueprint container sources by running the following command:
19+
+
20+
[source,terminal]
21+
----
22+
$ oc kustomize ~/manifests | grep "image:" | grep -oE '[^ ]+$' | while read line; do echo -e "[[containers]]\nsource = \"${line}\"\n"; done >><my_blueprint>.toml
23+
----
24+
25+
. Push the updated blueprint to Image Builder by running the following command:
26+
+
27+
[source, terminal]
28+
----
29+
$ sudo composer-cli blueprints push <my_blueprint>.toml
30+
----
31+
32+
. If your workload containers are located in a private repository, you must provide Image Builder with the necessary pull secrets:
33+
34+
.. Set the `auth_file_path` in the `[containers]` section of the `osbuilder worker` configuration in the `/etc/osbuild-worker/osbuild-worker.toml` file to point to the pull secret.
35+
36+
.. If needed, create a directory and file for the pull secret, for example:
37+
+
38+
.Example directory and file
39+
+
40+
[source,terminal]
41+
----
42+
[containers]
43+
auth_file_path = "/<path>/pull-secret.json" <1>
44+
----
45+
<1> Use the custom location previously set for copying and retrieving images.
46+
47+
. Build the container image by running the following command:
48+
+
49+
[source,terminal]
50+
----
51+
$ sudo composer-cli compose start-ostree <my_blueprint> edge-commit
52+
----
53+
54+
. Proceed with your preferred `rpm-ostree` image flow, such as waiting for the build to complete, exporting the image and integrating it into your `rpm-ostree` repository or creating a bootable ISO.

0 commit comments

Comments
 (0)