7장. Build and deploy serverless workflows
To deploy a workflow and make it available in the Orchestrator plugin, follow these main steps:
- Building workflow images
- Generating workflow manifests
- Deploying workflows to a cluster
This process moves the workflow from your local machine to deployment on a cluster.
7.1. Benefits of workflow images 링크 복사링크가 클립보드에 복사되었습니다!
While the OpenShift Serverless Logic Operator supports the building of workflows dynamically, this approach is primarily for experimentation. For production deployments, building images is the preferred method due to the following reasons:
- Production readiness: Prebuilt images can be scanned, secured, and tested before going live.
-
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
gitopsprofile, which expects a prebuilt image. - Testing and quality: Building an image gives you more control over the testing process.
7.1.1. Project structure overview 링크 복사링크가 클립보드에 복사되었습니다!
The project utilizes Quarkus project layout (Maven project structure). This structure is illustrated by the following 01_basic workflow example:
01_basic
├── pom.xml
├── README.md
└── src
└── main
├── docker
│ ├── Dockerfile.jvm
│ ├── Dockerfile.legacy-jar
│ ├── Dockerfile.native
│ └── Dockerfile.native-micro
└── resources
├── application.properties
├── basic.svg
├── basic.sw.yaml
├── schemas
│ ├── basic__main-schema.json
│ └── workflow-output-schema.json
└── secret.properties
The main workflow resources are located under the src/main/resources/ directory.
The kn-workflow CLI generated this project structure. You can try generating the structure yourself by following the Getting Started guide. For more information on the Quarkus project, see Creating your first application.
7.1.2. Creating and running your serverless workflow project locally 링크 복사링크가 클립보드에 복사되었습니다!
The kn-workflow CLI is an essential tool that generates workflow manifests and project structures. To ensure successful development and immediate testing, begin developing a new serverless workflow locally by completing the following steps:
Procedure
Use the
kn-workflowCLI to create a new workflow project, which adheres to the Quarkus structure as shown in the following example:kn-workflow quarkus create --name <specify project name, for example ,00_new_project>Edit the workflow, add schema and specific files, and run it locally from project folder as shown in the following example:
kn-workflow quarkus runRun the workflow locally using the
kn-workflow runwhich pulls the following image:registry.redhat.io/openshift-serverless-1/logic-swf-devmode-rhel8:1.36.0For building the workflow image, the
kn-workflowCLI pulls the following images:registry.redhat.io/openshift-serverless-1/logic-swf-builder-rhel8:1.36.0-8 registry.access.redhat.com/ubi9/openjdk-17:1.21-2