Skip to content

Commit dc98a9a

Browse files
GitHub Actionsjmagak
authored andcommitted
Building and Deploying Serverless Workflows
1 parent 020ab2f commit dc98a9a

10 files changed

+305
-1
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
:_mod-docs-content-type: ASSEMBLY
2+
3+
ifndef::context[]
4+
[id="assembly-building-and-deploying-serverless-workflows"]
5+
endif::[]
6+
ifdef::context[]
7+
[id="assembly-building-and-deploying-serverless-workflows"]
8+
endif::[]
9+
:context: orchestrator-rhdh
10+
= Building and deploying serverless workflows
11+
12+
The Orchestrator provides a way to run workflows directly from {product-custom-resource-type} and {product}. This guide takes you through the lifecycle of running a workflow locally on your machine to having it deployed on a cluster and available in the Orchestrator plugin.
13+
14+
The overall process involves the following main steps, which can often be accomplished from a single script:
15+
16+
* Building workflow images
17+
* Generating workflow manifests
18+
* Deploying workflows to a cluster
19+
20+
// why build workflow images
21+
include::modules/orchestrator/con-why-build-workflow-images.adoc[leveloffset=+1]
22+
23+
// project structure
24+
include::modules/orchestrator/con-project-structure-overview.adoc[leveloffset=+1]
25+
26+
// building locally and generating artifacts
27+
include::modules/orchestrator/proc-building-locally.adoc[leveloffset=+1]
28+
29+
include::modules/orchestrator/con-build-sh-script-and-its-uses.adoc[leveloffset=+1]
30+
31+
include::modules/orchestrator/con-environment-variables-supported-by-the-build-script.adoc[leveloffset=+1]
32+
33+
include::modules/orchestrator/proc-building-the-01-basic-workflow.adoc[leveloffset=+1]
34+
35+
include::modules/orchestrator/con-generated-workflow-manifests.adoc[leveloffset=+1]
36+
37+
include::modules/orchestrator/proc-deploying-workflows-on-a-cluster.adoc[leveloffset=+1]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
:_mod-docs-content-type: CONCEPT
2+
3+
[id="con-build-sh-script-and-its-uses.adoc_{context}"]
4+
= Uses of the `build-sh` script and important flags
5+
6+
The script does the following in the order provided here:
7+
8+
* Generates workflow manifests using the `kn-workflow` CLI.
9+
* Builds the workflow image using `podman` or `docker`.
10+
* Optional: The script pushes the images to an image registry and deploys the workflow using `kubectl`.
11+
12+
You can check the help menu of the script as shown in the following example:
13+
14+
.Script usage
15+
[source,bash]
16+
----
17+
./scripts/build.sh [flags]
18+
----
19+
20+
The following flags are essential for running the script:
21+
22+
[cols="1,3", options="header"]
23+
|===
24+
|Flag |Description
25+
|-i, --image (required) |Full image path, e.g. quay.io/orchestrator/demo:latest
26+
|-w, --workflow-directory |Workflow source directory (default: current directory)
27+
|-m, --manifests-directory |Where to save generated manifests
28+
|--push |Push the image to the registry
29+
|--deploy |Deploy the workflow
30+
|-h, --help |Show help message
31+
|===
32+
33+
[TIP]
34+
The script also supports builder and runtime image overrides, namespace targeting, and persistence flags.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
:_mod-docs-content-type: PROCEDURE
2+
3+
[id="con-environment-variables-supported-by-the-build-script.adoc_{context}"]
4+
= Environment variables supported by the build script and required tools
5+
6+
The `build-sh` script supports the following environment variables to customize the workflow build process without modifying the script itself.
7+
8+
* `QUARKUS_EXTENSIONS`
9+
10+
The `QUARKUS_EXTENSIONS` variable specifies additional Quarkus extensions required by the workflow.
11+
12+
This variable takes the format of a comma-separated list of fully qualified extension IDs as shown in the following example:
13+
+
14+
[source,yaml]
15+
----
16+
export QUARKUS_EXTENSIONS="io.quarkus:quarkus-smallrye-reactive-messaging-kafka"
17+
----
18+
+
19+
Add Kafka messaging support or other integrations at build time.
20+
21+
* `MAVEN_ARGS_APPEND`
22+
23+
The `MAVEN_ARGS_APPEND` variable appends additional arguments to the Maven build command.
24+
This variable takes the format of the string of Maven CLI arguments as shown in the following example:
25+
+
26+
[source,yaml]
27+
----
28+
export MAVEN_ARGS_APPEND="-DmaxYamlCodePoints=35000000"
29+
----
30+
31+
.Required tools
32+
[cols="1,3", options="header"]
33+
|===
34+
|Tool |Conceptual Purpose
35+
|podman or docker |Container runtime required for building the workflow images.
36+
|kubectl |Kubernetes CLI
37+
|yq JSON |processor
38+
|curl, git, find, |which Shell utilities
39+
|kn-workflow |CLI for generating workflow manifests
40+
|===
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
:_mod-docs-content-type: PROCEDURE
2+
3+
[id="con-generated-workflow-manifests.adoc_{context}"]
4+
= Generated workflow manifests
5+
6+
The following example is an illustration of what is generated under the `01_basic/manifests`:
7+
+
8+
[source,yaml]
9+
----
10+
01_basic/manifests
11+
├── 00-secret_basic-secrets.yaml
12+
├── 01-configmap_basic-props.yaml
13+
├── 02-configmap_01-basic-resources-schemas.yaml
14+
└── 03-sonataflow_basic.yaml
15+
----
16+
17+
Here is a quick overview of each of these manifests:
18+
19+
`00-secret_basic-secrets.yaml`::
20+
Contains secrets from `01_basic/src/main/resources/secret.properties`.
21+
Values are not required at this stage as you can set them later (after applying CRs or when using GitOps).
22+
23+
[Important]
24+
====
25+
In OpenShift Serverless Logic `v1.35`, after updating a secret, you must manually restart the workflow Pod for changes to apply.
26+
====
27+
28+
`01-configmap_basic-props.yaml`::
29+
Holds application properties from application.properties.
30+
Any change to this ConfigMap triggers an automatic Pod restart.
31+
32+
`02-configmap_01-basic-resources-schemas.yaml`::
33+
Contains JSON schemas from src/main/resources/schemas.
34+
Note: When using the GitOps profile, this ConfigMap (and similar ones like specs) does not need to be deployed.
35+
36+
`03-sonataflow_basic.yaml`::
37+
The SonataFlow custom resource (CR) that defines the workflow.
38+
A few important parts:
39+
40+
.The image and secrets mounting example:
41+
[source,yaml]
42+
----
43+
podTemplate:
44+
container:
45+
image: quay.io/orchestrator/demo-basic
46+
resources: {}
47+
envFrom:
48+
- secretRef:
49+
name: basic-secrets
50+
----
51+
52+
.The persistence configuration example:
53+
[source,yaml]
54+
----
55+
persistence:
56+
postgresql:
57+
secretRef:
58+
name: sonataflow-psql-postgresql
59+
userKey: postgres-username
60+
passwordKey: postgres-password
61+
serviceRef:
62+
name: sonataflow-psql-postgresql
63+
port: 5432
64+
databaseName: sonataflow
65+
databaseSchema: basic
66+
----
67+
68+
If you need to connect to an external database, you must replace `serviceRef` with a `jdbcUrl`. See link:https://sonataflow.org/serverlessworkflow/latest/cloud/operator/enabling-jobs-service.html#_using_the_persistence_field_defined_in_the_sonataflowplatform_cr[SonataFlow Guides] for more information.
69+
here.
70+
71+
By default, all the manifests are generated without a namespace. You can specify a namespace to the script by the `--namespace` flag if you know the target namespace in advance. Otherwise, the namespace needs to be provided when applying the manifests to the cluster. See link:https://sonataflow.org/serverlessworkflow/latest/cloud/operator/configuring-workflows.html[Configuring Workflow Services].
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
:_mod-docs-content-type: CONCEPT
2+
3+
[id="con-project-structure-overview.adoc_{context}"]
4+
= Project structure overview
5+
6+
We focus on a *Quarkus project layout* (Maven project structure), specifically the following `01_basic` workflow example:
7+
8+
[source, yaml]
9+
----
10+
01_basic
11+
├── pom.xml
12+
├── README.md
13+
└── src
14+
└── main
15+
├── docker
16+
│ ├── Dockerfile.jvm
17+
│ ├── Dockerfile.legacy-jar
18+
│ ├── Dockerfile.native
19+
│ └── Dockerfile.native-micro
20+
└── resources
21+
├── application.properties
22+
├── basic.svg
23+
├── basic.sw.yaml
24+
├── schemas
25+
│ ├── basic__main-schema.json
26+
│ └── workflow-output-schema.json
27+
└── secret.properties
28+
----
29+
30+
The main workflow resources are located under the `src/main/resources/` directory.
31+
32+
The structure of this project was generated using the `kn-workflow CLI`. For more information on the Quarkus project, see link:https://quarkus.io/guides/getting-started[Creating your first application].
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
:_mod-docs-content-type: CONCEPT
2+
3+
[id="con-why-build-workflow-images.adoc_{context}"]
4+
= Why build workflow images?
5+
6+
While the OpenShift Serverless Logic Operator supports building workflows on the fly, this approach is primarily for experimentation. For production deployments, building images is preferred method due to the following reasons:
7+
8+
* Production readiness: Prebuilt images can be scanned, secured, and tested before going live.
9+
* GitOps compatibility: The Orchestrator relies on a central OpenShift Serverless Logic Operator instance to track workflows and their state. To use this tracking service, you must deploy workflows with the `gitops` profile, which expects a prebuilt image.
10+
* Testing & quality: Building an image gives you more control over the testing process.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
:_mod-docs-content-type: PROCEDURE
2+
3+
[id="proc-building-locally.adoc_{context}"]
4+
= Building workflow images locally
5+
6+
You can use the build script (`build.sh`) to build workflow images. You can run it either locally or inside a container. This section highlights how build workflow images locally.
7+
8+
.Prerequisites
9+
10+
* You have cloned the project as shown in the following example:
11+
12+
[source, yaml]
13+
----
14+
git clone [email protected]:rhdhorchestrator/orchestrator-demo.git
15+
cd orchestrator-demo
16+
----
17+
18+
.Procedure
19+
20+
. You have cloned the project.
21+
22+
. Check the help menu of the script:
23+
[source,yaml]
24+
----
25+
./scripts/build.sh --help
26+
----
27+
28+
. Execute the `build.sh` script, providing the required flags: image path (-i), workflow source directory (-w), and manifests output directory (-m).
29+
30+
[IMPORTANT]
31+
====
32+
You must specify the full target image path with a tag as shown in the following example:
33+
34+
[source,yaml]
35+
----
36+
./scripts/build.sh --image=quay.io/orchestrator/demo-basic:test -w 01_basic/ -m 01_basic/manifests
37+
----
38+
====
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
:_mod-docs-content-type: PROCEDURE
2+
3+
[id="proc-building-the-01-basic-workflow.adoc_{context}"]
4+
= Building the `01_basic` workflow
5+
6+
To run the script from the root directory of the repository, use the `-w` flag to point to the workflow directory, and specify the output directory with `-m`.
7+
8+
.Prerequisites
9+
10+
* You have specified the target image using a tag.
11+
12+
.Procedure
13+
14+
. Run the following command:
15+
+
16+
[source,bash]
17+
----
18+
./scripts/build.sh --image=quay.io/orchestrator/demo-basic:test -w 01_basic/ -m 01_basic/manifests
19+
----
20+
21+
This build command produces the following two artifacts:
22+
23+
* A workflow image and Kubernetes manifests: `quay.io/orchestrator/demo-basic:test` and tagged as `latest`.
24+
* Kubernetes manifests under: `01_basic/manifests/`
25+
26+
. Optional: You can add the `--push` flag to automatically push the image after building. Otherwise, pushing manually is mandatory before deploying.
27+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
:_mod-docs-content-type: PROCEDURE
2+
3+
[id="proc-deploying-workflows-on-a-cluster.adoc_{context}"]
4+
= Deploying workflows on a cluster
5+
6+
.Prerequisites
7+
8+
* You have an OpenShift Container Platform (OCP) cluster with the following versions of components installed:
9+
10+
* {product} ({product-very-short}) v1.5
11+
* Orchestrator plugins v1.4 or v1.5
12+
* OpenShift Serverless v1.35
13+
* OpenShift Serverless Logic v1.35

titles/orchestrator/master.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ include::artifacts/attributes.adoc[]
88

99
include::assemblies/assembly-orchestrator-rhdh.adoc[leveloffset=+1]
1010

11-
include::assemblies/assembly-install-rhdh-orchestrator.adoc[leveloffset=+1]
11+
include::assemblies/assembly-install-rhdh-orchestrator.adoc[leveloffset=+1]
12+
13+
include::assemblies/assembly-building-and-deploying-serverless-workflows.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)