Serverless Logic


Red Hat OpenShift Serverless 1.34

Introduction to OpenShift Serverless Logic

Red Hat OpenShift Documentation Team

Abstract

This document provides an overview of OpenShift Serverless Logic features.

Chapter 1. Getting started

You can create and run the OpenShift Serverless Logic workflows locally.

1.1.1. Creating a workflow

You can use the create command with kn workflow to set up a new OpenShift Serverless Logic project in your current directory.

Prerequisites

  • You have installed the OpenShift Serverless Logic kn-workflow CLI plugin.

Procedure

  1. Create a new OpenShift Serverless Logic workflow project by running the following command:

    $ kn workflow create
    Copy to Clipboard Toggle word wrap

    By default, the generated project name is new-project. You can change the project name by using the [-n|--name] flag as follows:

    Example command

    $ kn workflow create --name my-project
    Copy to Clipboard Toggle word wrap

1.1.2. Running a workflow locally

You can use the run command with kn workflow to build and run your OpenShift Serverless Logic workflow project in your current directory.

Prerequisites

  • You have installed Podman on your local machine.
  • You have installed the OpenShift Serverless Logic kn-workflow CLI plugin.
  • You have created an OpenShift Serverless Logic workflow project.

Procedure

  1. Run the following command to build and run your OpenShift Serverless Logic workflow project:

    $ kn workflow run
    Copy to Clipboard Toggle word wrap

    When the project is ready, the Development UI automatically opens in your browser on localhost:8080/q/dev-ui and you will find the Serverless Workflow Tools tile available. Alternatively, you can access the tool directly using http://localhost:8080/q/dev-ui/org.apache.kie.sonataflow.sonataflow-quarkus-devui/workflows.

Note

You can execute a workflow locally using a container that runs on your machine. Stop the container with Ctrl+C.

1.2. Deploying workflows

You can deploy the Serverless Logic workflows on the cluster in two modes: Dev mode and Preview mode.

1.2.1. Deploying workflows in Dev mode

You can deploy your local workflow on OpenShift Container Platform in Dev mode. You can use this deployment to experiment and modify your workflow directly on the cluster, seeing changes almost immediately. Dev mode is designed for development and testing purposes. It is ideal for initial development stages and for testing new changes.

Prerequisites

  • You have OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Create the workflow configuration YAML file.

    Example workflow-dev.yaml file

    apiVersion: sonataflow.org/v1alpha08
    kind: SonataFlow
    metadata:
      name: greeting 
    1
    
      annotations:
        sonataflow.org/description: Greeting example on k8s!
        sonataflow.org/version: 0.0.1
        sonataflow.org/profile: dev 
    2
    
    spec:
      flow:
        start: ChooseOnLanguage
        functions:
          - name: greetFunction
            type: custom
            operation: sysout
        states:
          - name: ChooseOnLanguage
            type: switch
            dataConditions:
              - condition: "${ .language == \"English\" }"
                transition: GreetInEnglish
              - condition: "${ .language == \"Spanish\" }"
                transition: GreetInSpanish
            defaultCondition: GreetInEnglish
          - name: GreetInEnglish
            type: inject
            data:
              greeting: "Hello from JSON Workflow, "
            transition: GreetPerson
          - name: GreetInSpanish
            type: inject
            data:
              greeting: "Saludos desde JSON Workflow, "
            transition: GreetPerson
          - name: GreetPerson
            type: operation
            actions:
              - name: greetAction
                functionRef:
                  refName: greetFunction
                  arguments:
                    message:  ".greeting + .name"
            end: true
    Copy to Clipboard Toggle word wrap

    1
    is a workflow_name
    2
    indicates that you must deploy the workflow in Dev mode
  2. To deploy the application, apply the YAML file by entering the following command:

    $ oc apply -f <filename> -n <your_namespace>
    Copy to Clipboard Toggle word wrap
  3. Verify the deployment and check the status of the deployed workflow by entering the following command:

    $ oc get workflow -n <your_namespace> -w
    Copy to Clipboard Toggle word wrap

    Ensure that your workflow is listed and the status is Running or Completed.

  4. Edit the workflow directly in the cluster by entering the following command:

    $ oc edit sonataflow <workflow_name> -n <your_namespace>
    Copy to Clipboard Toggle word wrap
  5. After editing, save the changes. The OpenShift Serverless Logic Operator detects the changes and updates the workflow accordingly.

Verification

  1. To ensure the changes are applied correctly, verify the status and logs of the workflow by entering the following commands:

    1. View the status of the workflow by running the following command:

      $ oc get sonataflows -n <your_namespace>
      Copy to Clipboard Toggle word wrap
    2. View the workflow logs by running the following command:

      $ oc logs <workflow_pod_name> -n <your_namespace>
      Copy to Clipboard Toggle word wrap

Next steps

  1. After completing the testing, delete the resources to avoid unnecessary usage by running the following command:

    $ oc delete sonataflow <workflow_name> -n <your_namespace>
    Copy to Clipboard Toggle word wrap

1.2.2. Deploying workflows in Preview mode

You can deploy your local workflow on OpenShift Container Platform in Preview mode. This allows you to experiment and modify your workflow directly on the cluster, seeing changes almost immediately. Preview mode is used for final testing and validation before deploying to production. It also ensures that workflows will run smoothly in a production-like setting.

Prerequisites

  • You have an OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to an OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

To deploy a workflow in Preview mode, OpenShift Serverless Logic Operator uses the build system on OpenShift Container Platform, which automatically creates the image for deploying your workflow.

The following sections explain how to build and deploy your workflow on a cluster using the OpenShift Serverless Logic Operator with a SonataFlow custom resource.

1.2.2.1. Configuring workflows in Preview mode

If your scenario requires strict policies for image usage, such as security or hardening constraints, replace the default image used by the OpenShift Serverless Logic Operator to build the final workflow container image.

By default, the OpenShift Serverless Logic Operator uses the image distributed in the official Red Hat Registry to build workflows. If your scenario requires strict policies for image use, such as security or hardening constraints, you can replace the default image.

To change this image, you edit the SonataFlowPlatform custom resource (CR) in the namespace where you deployed your workflows.

Prerequisites

  • You have an OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to an OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. List the SonataFlowPlatform resources in your namespace by running the following command:

    $ oc get sonataflowplatform -n <your_namespace> 
    1
    Copy to Clipboard Toggle word wrap
    1
    Replace <your_namespace> with the name of your namespace.
  2. Patch the SonataFlowPlatform resource with the new builder image by running the following command:

    $ oc patch sonataflowplatform <name> --patch 'spec:\n  build:\n    config:\n      baseImage: <your_new_image_full_name_with_tag>' -n <your_namespace>
    Copy to Clipboard Toggle word wrap

Verification

  1. Verify that the SonataFlowPlatform CR has been patched correctly by running the following command:

    $ oc describe sonataflowplatform <name> -n <your_namespace> 
    1
    Copy to Clipboard Toggle word wrap
    1
    Replace <name> with the name of your SonataFlowPlatform resource and <your_namespace> with the name of your namespace.

    Ensure that the baseImage field under spec.build.config reflects the new image.

The OpenShift Serverless Logic Operator uses the logic-operator-rhel8-builder-config config map custom resource (CR) in its openshift-serverless-logicOpenShift Serverless Logic Operator installation namespace to configure and run the workflow build process. You can change the Dockerfile entry in this config map to adjust the Dockerfile to your needs.

Important

Modifying the Dockerfile can break the build process.

Note

This example is for reference only. The actual version might be slightly different. Do not use this example for your installation.

Example logic-operator-rhel8-builder-config config map CR

apiVersion: v1
data:
  DEFAULT_WORKFLOW_EXTENSION: .sw.json
  Dockerfile: |
    FROM registry.redhat.io/openshift-serverless-1/logic-swf-builder-rhel8:1.33.0 AS builder

    # Variables that can be overridden by the builder
    # To add a Quarkus extension to your application
    ARG QUARKUS_EXTENSIONS
    # Args to pass to the Quarkus CLI add extension command
    ARG QUARKUS_ADD_EXTENSION_ARGS
    # Additional java/mvn arguments to pass to the builder
    ARG MAVEN_ARGS_APPEND

    # Copy from build context to skeleton resources project
    COPY --chown=1001 . ./resources

    RUN /home/kogito/launch/build-app.sh ./resources

    #=============================
    # Runtime Run
    #=============================
    FROM registry.access.redhat.com/ubi9/openjdk-17:latest

    ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'

    # We make four distinct layers so if there are application changes, the library layers can be re-used
    COPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/lib/ /deployments/lib/
    COPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/*.jar /deployments/
    COPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/app/ /deployments/app/
    COPY --from=builder --chown=185 /home/kogito/serverless-workflow-project/target/quarkus-app/quarkus/ /deployments/quarkus/

    EXPOSE 8080
    USER 185
    ENV AB_JOLOKIA_OFF=""
    ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
    ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
kind: ConfigMap
metadata:
  name: sonataflow-operator-builder-config
  namespace: sonataflow-operator-system
Copy to Clipboard Toggle word wrap

1.2.2.1.3. Changing resource requirements

You can specify resource requirements for the internal builder pods, by creating or editing a SonataFlowPlatform resource in the workflow namespace.

Example SonataFlowPlatform resource

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform
spec:
  build:
    template:
      resources:
        requests:
          memory: "64Mi"
          cpu: "250m"
        limits:
          memory: "128Mi"
          cpu: "500m"
Copy to Clipboard Toggle word wrap

Note

Only one SonataFlowPlatform resource is allowed per namespace. Fetch and edit the resource that the OpenShift Serverless Logic Operator created for you instead of trying to create another resource.

You can fine-tune the resource requirements for a particular workflow. Each workflow instance has a SonataFlowBuild instance created with the same name as the workflow. You can edit the SonataFlowBuild custom resource (CR) and specify the parameters as follows:

Example of SonataFlowBuild CR

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowBuild
metadata:
  name: my-workflow
spec:
  resources:
    requests:
      memory: "64Mi"
      cpu: "250m"
    limits:
      memory: "128Mi"
      cpu: "500m"
Copy to Clipboard Toggle word wrap

These parameters apply only to new build instances.

You can customize the build process by passing build arguments to the SonataFlowBuild instance or setting default build arguments in the SonataFlowPlatform resource.

Prerequisites

  • You have an OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to an OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Check for the existing SonataFlowBuild instance by running the following command:

    $ oc get sonataflowbuild <name> -n <namespace> 
    1
    Copy to Clipboard Toggle word wrap
    1
    Replace <name> with the name of your SonataFlowBuild instance and <namespace> with your namespace.
  2. Add build arguments to the SonataFlowBuild instance by running the following command:

    $ oc edit sonataflowbuild <name> -n <namespace>
    Copy to Clipboard Toggle word wrap
  3. Add the desired build arguments under the .spec.buildArgs field of the SonataFlowBuild instance:

    apiVersion: sonataflow.org/v1alpha08
    kind: SonataFlowBuild
    metadata:
      name: <name>  
    1
    
    spec:
      buildArgs:
        - name: <argument_1>
          value: <value_1>
        - name: <argument_2>
          value: <value_2>
    Copy to Clipboard Toggle word wrap
    1
    The name of the existing SonataFlowBuild instance.
  4. Save the file and exit.

    A new build with the updated configuration starts.

  5. Set the default build arguments in the SonataFlowPlatform resource by running the following command:

    $ oc edit sonataflowplatform <name> -n <namespace>
    Copy to Clipboard Toggle word wrap
  6. Add the desired build arguments under the .spec.buildArgs field of the SonataFlowPlatform resource:

    apiVersion: sonataflow.org/v1alpha08
    kind: SonataFlowPlatform
    metadata:
      name: <name> 
    1
    
    spec:
      build:
        template:
          buildArgs:
            - name: <argument_1>
              value: <value_1>
            - name: <argument_2>
              value: <value_2>
    Copy to Clipboard Toggle word wrap
    1
    The name of the existing SonataFlowPlatform resource.
  7. Save the file and exit.

You can set environment variables to the SonataFlowBuild internal builder pod. These variables are valid for the build context only and are not set on the final built workflow image.

Prerequisites

  • You have an OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to an OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Check for existing SonataFlowBuild instance by running the following command:

    $ oc get sonataflowbuild <name> -n <namespace>
    Copy to Clipboard Toggle word wrap

    Replace <name> with the name of your SonataFlowBuild instance and <namespace> with your namespace.

  2. Edit the SonataFlowBuild instance by running the following command:

    $ oc edit sonataflowbuild <name> -n <namespace>
    Copy to Clipboard Toggle word wrap

    Example SonataFlowBuild instance

    apiVersion: sonataflow.org/v1alpha08
    kind: SonataFlowBuild
    metadata:
      name: <name>
    spec:
      envs:
        - name: <env_variable_1>
          value: <value_1>
        - name: <env_variable_2>
          value: <value_2>
    Copy to Clipboard Toggle word wrap

  3. Save the file and exit.

    A new with the updated configuration starts.

    Alternatively, you can set the enviroments in the SonataFlowPlatform, so that every new build instances will use it as a template.

    Example SonataFlowPlatform instance

    apiVersion: sonataflow.org/v1alpha08
    kind: SonataFlowPlatform
    metadata:
      name: <name>
    spec:
      build:
        template:
          envs:
            - name: <env_variable_1>
              value: <value_1>
            - name: <env_variable_2>
              value: <value_2>
    Copy to Clipboard Toggle word wrap

1.2.2.1.6. Changing the base builder image

You can modify the default builder image used by the OpenShift Serverless Logic Operator by editing the logic-operator-rhel8-builder-config config map.

Prerequisites

  • You have an OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to an OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Edit the logic-operator-rhel8-builder-config config map by running the following command:

    $ oc edit cm/logic-operator-rhel8-builder-config -n openshift-serverless-logic
    Copy to Clipboard Toggle word wrap
  2. Modify the dockerfile entry.

    In your editor, locate the Dockerfile entry and change the first line to the desired image.

    Example

    data:
      Dockerfile: |
        FROM registry.redhat.io/openshift-serverless-1/logic-swf-builder-rhel8:1.33.0
        # Change the image to the desired one
    Copy to Clipboard Toggle word wrap

  3. Save the changes.
1.2.2.2. Building and deploying your workflow

You can create a SonataFlow custom resource (CR) on OpenShift Container Platform and OpenShift Serverless Logic Operator builds and deploys the workflow.

Prerequisites

  • You have an OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to an OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Create a workflow YAML file similar to the following:

    apiVersion: sonataflow.org/v1alpha08
    kind: SonataFlow
    metadata:
      name: greeting
      annotations:
        sonataflow.org/description: Greeting example on k8s!
        sonataflow.org/version: 0.0.1
    spec:
      flow:
        start: ChooseOnLanguage
        functions:
          - name: greetFunction
            type: custom
            operation: sysout
        states:
          - name: ChooseOnLanguage
            type: switch
            dataConditions:
              - condition: "${ .language == \"English\" }"
                transition: GreetInEnglish
              - condition: "${ .language == \"Spanish\" }"
                transition: GreetInSpanish
            defaultCondition: GreetInEnglish
          - name: GreetInEnglish
            type: inject
            data:
              greeting: "Hello from JSON Workflow, "
            transition: GreetPerson
          - name: GreetInSpanish
            type: inject
            data:
              greeting: "Saludos desde JSON Workflow, "
            transition: GreetPerson
          - name: GreetPerson
            type: operation
            actions:
              - name: greetAction
                functionRef:
                  refName: greetFunction
                  arguments:
                    message:  ".greeting+.name"
            end: true
    Copy to Clipboard Toggle word wrap
  2. Apply the SonataFlow workflow definition to your OpenShift Container Platform namespace by running the following command:

    $ oc apply -f <workflow-name>.yaml -n <your_namespace>
    Copy to Clipboard Toggle word wrap

    Example command for the greetings-workflow.yaml file:

    $ oc apply -f greetings-workflow.yaml -n workflows
    Copy to Clipboard Toggle word wrap

  3. List all the build configurations by running the following command:

    $ oc get buildconfigs -n workflows
    Copy to Clipboard Toggle word wrap
  4. Get the logs of the build process by running the following command:

    $ oc logs buildconfig/<workflow-name> -n <your_namespace>
    Copy to Clipboard Toggle word wrap

    Example command for the greetings-workflow.yaml file:

    $ oc logs buildconfig/greeting -n workflows
    Copy to Clipboard Toggle word wrap

Verification

  1. To verify the deployment, list all the pods by running the following command:

    $ oc get pods -n <your_namespace>
    Copy to Clipboard Toggle word wrap

    Ensure that the pod corresponding to your workflow is running.

  2. Check the running pods and their logs by running the following command:

    $ oc logs pod/<pod-name> -n workflows
    Copy to Clipboard Toggle word wrap
1.2.2.3. Verifying workflow deployment

You can verify that your OpenShift Serverless Logic workflow is running by performing a test HTTP call from the workflow pod.

Prerequisites

  • You have an OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to an OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Create a workflow YAML file similar to the following:

    apiVersion: sonataflow.org/v1alpha08
    kind: SonataFlow
    metadata:
      name: greeting
      annotations:
        sonataflow.org/description: Greeting example on k8s!
        sonataflow.org/version: 0.0.1
    spec:
      flow:
        start: ChooseOnLanguage
        functions:
          - name: greetFunction
            type: custom
            operation: sysout
        states:
          - name: ChooseOnLanguage
            type: switch
            dataConditions:
              - condition: "${ .language == \"English\" }"
                transition: GreetInEnglish
              - condition: "${ .language == \"Spanish\" }"
                transition: GreetInSpanish
            defaultCondition: GreetInEnglish
          - name: GreetInEnglish
            type: inject
            data:
              greeting: "Hello from JSON Workflow, "
            transition: GreetPerson
          - name: GreetInSpanish
            type: inject
            data:
              greeting: "Saludos desde JSON Workflow, "
            transition: GreetPerson
          - name: GreetPerson
            type: operation
            actions:
              - name: greetAction
                functionRef:
                  refName: greetFunction
                  arguments:
                    message:  ".greeting+.name"
            end: true
    Copy to Clipboard Toggle word wrap
  2. Create a route for the workflow service by running the following command:

    $ oc expose svc/<workflow-service-name> -n workflows
    Copy to Clipboard Toggle word wrap

    This command creates a public URL to access the workflow service.

  3. Set an environment variable for the public URL by running the following command:

    $ WORKFLOW_SVC=$(oc get route/<workflow-service-name> -n <namespace> --template='{{.spec.host}}')
    Copy to Clipboard Toggle word wrap
  4. Make an HTTP call to the workflow to send a POST request to the service by running the following command:

    $ curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{<"your": "json_payload">}' http://$WORKFLOW_SVC/<endpoint>
    Copy to Clipboard Toggle word wrap

    Example output

    {
      "id": "b5fbfaa3-b125-4e6c-9311-fe5a3577efdd",
      "workflowdata": {
        "name": "John",
        "language": "English",
        "greeting": "Hello from JSON Workflow, "
      }
    }
    Copy to Clipboard Toggle word wrap

    This output shows an example of the expected response if the workflow is running.

1.2.2.4. Restarting a build

To restart a build, you can add or edit the sonataflow.org/restartBuild: true annotation in the SonataFlowBuild instance. Restarting a build is necessary if there is a problem with your workflow or the initial build revision.

Prerequisites

  • You have an OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to an OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Check if the SonataFlowBuild instance exists by running the following command:

    $ oc get sonataflowbuild <name> -n <namespace>
    Copy to Clipboard Toggle word wrap
  2. Edit the SonataFlowBuild instance by running the following command:

    $ oc edit sonataflowbuild/<name> -n <namespace>
    Copy to Clipboard Toggle word wrap

    Replace <name> with the name of your SonataFlowBuild instance and <namespace> with the namespace where your workflow is deployed.

  3. Add the sonataflow.org/restartBuild: true annotation to restart the build.

    apiVersion: sonataflow.org/v1alpha08
    kind: SonataFlowBuild
    metadata:
      name: <name>
      annotations:
        sonataflow.org/restartBuild: true
    Copy to Clipboard Toggle word wrap

    This action triggers the OpenShift Serverless Logic Operator to start a new build of the workflow.

  4. To monitor the build process, check the build logs by running the following command:

    $ oc logs buildconfig/<name> -n <namespace>
    Copy to Clipboard Toggle word wrap

    Replace <name> with the name of your SonataFlowBuild instance and <namespace> with the namespace where your workflow is deployed.

1.2.3. Editing a workflow

When the OpenShift Serverless Logic Operator deploys a workflow service, it creates two config maps to store runtime properties:

  • User properties: Defined in a ConfigMap named after the SonataFlow object with the suffix -props. For example, if your workflow name is greeting, then the ConfigMap name is greeting-props.
  • Managed properties: Defined in a ConfigMap named after the SonataFlow object with the suffix -managed-props. For example, if your workflow name is greeting, then the ConfigMap name is greeting-managed-props.
Note

Managed properties always override any user property with the same key name and cannot be edited by the user. Any change would be overwritten by the Operator at the next reconciliation cycle.

Prerequisites

  • You have OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Open and edit the ConfigMap by running the following command:

    $ oc edit cm <workflow_name>-props -n <namespace>
    Copy to Clipboard Toggle word wrap

    Replace <workflow_name> with the name of your workflow and <namespace> with the namespace where your workflow is deployed.

  2. Add the properties in the application.properties section.

    Example of a workflow properties stored within a ConfigMap:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      labels:
        app: greeting
      name: greeting-props
      namespace: default
    data:
      application.properties: |
        my.properties.key = any-value
    Copy to Clipboard Toggle word wrap

    Ensure the properties are correctly formatted to prevent the Operator from replacing your configuration with the default one.

  3. After making the necessary changes, save the file and exit the editor.

1.2.4. Testing a workflow

To verify that your OpenShift Serverless Logic workflow is running correctly, you can perform a test HTTP call from the relevant pod.

Prerequisites

  • You have OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. To create a route for the specified service in your namespace by running the following command:

    $ oc expose svc <service_name> -n <namespace>
    Copy to Clipboard Toggle word wrap
  2. To fetch the URL for the newly exposed service by running the following command:

    $ WORKFLOW_SVC=$(oc get route/<service_name> --template='{{.spec.host}}')
    Copy to Clipboard Toggle word wrap
  3. Perform a test HTTP call and send a POST request by running the following command:

    $ curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '<request_body>' http://$WORKFLOW_SVC/<endpoint>
    Copy to Clipboard Toggle word wrap
  4. Verify the response to ensure the workflow is functioning as expected.

1.2.5. Troubleshooting a workflow

The OpenShift Serverless Logic Operator deploys its pod with health check probes to ensure the Workflow runs in a healthy state. If changes cause these health checks to fail, the pod will stop responding.

Prerequisites

  • You have OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Check the workflow status by running the following command:

    $ oc get workflow <name> -o jsonpath={.status.conditions} | jq .
    Copy to Clipboard Toggle word wrap
  2. To fetch and analyze the the logs from the workflow’s deployment, run the following command:

    $ oc logs deployment/<workflow_name> -f
    Copy to Clipboard Toggle word wrap

1.2.6. Deleting a workflow

You can use the oc delete command to delete your OpenShift Serverless Logic workflow in your current directory.

Prerequisites

  • You have OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Verify that you have the correct file that defines the Workflow you want to delete. For example, workflow.yaml.
  2. Run the oc delete command to remove the Workflow from your specified namespace:

    $ oc delete -f <your_file> -n <your_namespace>
    Copy to Clipboard Toggle word wrap

    Replace <your_file> with the name of your Workflow file and <your_namespace> with your namespace.

Chapter 2. Managing services

2.1. Configuring OpenAPI services

The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface for HTTP APIs. You can understand a service’s capabilities without access to the source code, additional documentation, or network traffic inspection. When you define a service by using the OpenAPI, you can understand and interact with it using minimal implementation logic. Just as interface descriptions simplify lower-level programming, the OpenAPI Specification eliminates guesswork in calling a service.

2.1.1. OpenAPI function definition

OpenShift Serverless Logic allows the workflows to interact with remote services using an OpenAPI specfication reference in a function.

Example OpenAPI function definition

{
   "functions": [
      {
         "name": "myFunction1",
         "operation": "specs/myopenapi-file.yaml#myFunction1"
      }
   ]
}
Copy to Clipboard Toggle word wrap

The operation attribute is a string composed of the following parameters:

  • URI: The engine uses this to locate the specification file, such as classpath.
  • Operation identifier: You can find this identifier in the OpenAPI specification file.

OpenShift Serverless Logic supports the following URI schemes:

  • classpath: Use this for files located in the src/main/resources folder of the application project. classpath is the default URI scheme. If you do not define a URI scheme, the file location is src/main/resources/myopenapifile.yaml.
  • file: Use this for files located in the file system.
  • http or https: Use these for remotely located files.

Ensure the OpenAPI specification files are available during build time. OpenShift Serverless Logic uses an internal code generation feature to send requests at runtime. After you build the application image, OpenShift Serverless Logic will not have access to these files.

If the OpenAPI service you want to add to the workflow does not have a specification file, you can either create one or update the service to generate and expose the file.

To send REST requests that are based on the OpenAPI specification files, you must perform the following procedures:

  • Define the function references
  • Access the defined functions in the workflow states

Prerequisites

  • You have OpenShift Serverless Logic Operator installed on your cluster.
  • You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have access to the OpenAPI specification files.

Procedure

  1. To define the OpenAPI functions:

    1. Identify and access the OpenAPI specification files for the services you intend to invoke.
    2. Copy the OpenAPI specification files into your workflow service directory, such as <project_application_dir>/specs.

      The following example shows the OpenAPI specification for the multiplication REST service:

      Example multiplication REST service OpenAPI specification

      openapi: 3.0.3
      info:
        title: Generated API
        version: "1.0"
      paths:
        /:
          post:
            operationId: doOperation
            parameters:
              - in: header
                name: notUsed
                schema:
                  type: string
                required: false
            requestBody:
              content:
                application/json:
                  schema:
                    $ref: '#/components/schemas/MultiplicationOperation'
            responses:
              "200":
                description: OK
                content:
                  application/json:
                    schema:
                      type: object
                      properties:
                        product:
                          format: float
                          type: number
      components:
        schemas:
          MultiplicationOperation:
            type: object
            properties:
              leftElement:
                format: float
                type: number
              rightElement:
                format: float
                type: number
      Copy to Clipboard Toggle word wrap

    3. To define functions in the workflow, use the operationId from the OpenAPI specification to reference the desired operations in your function definitions.

      Example function definitions in the temperature conversion application

      {
         "functions": [
           {
             "name": "multiplication",
             "operation": "specs/multiplication.yaml#doOperation"
           },
           {
             "name": "subtraction",
             "operation": "specs/subtraction.yaml#doOperation"
           }
         ]
      }
      Copy to Clipboard Toggle word wrap

    4. Ensure that your function definitions reference the correct paths to the OpenAPI files stored in the <project_application_dir>/specs directory.
  2. To access the defined functions in the workflow states:

    1. Define workflow actions to call the function definitions you added. Ensure each action references a function defined earlier.
    2. Use the functionRef attribute to refer to the specific function by its name. Map the arguments in the functionRef using the parameters defined in the OpenAPI specification.

      The following example shows about mapping parameters in the request path instead of request body, you can refer to the following PetStore API example:

      Example for mapping function arguments in workflow

      {
         "states": [
          {
            "name": "SetConstants",
            "type": "inject",
            "data": {
              "subtractValue": 32.0,
              "multiplyValue": 0.5556
            },
            "transition": "Computation"
          },
          {
            "name": "Computation",
            "actionMode": "sequential",
            "type": "operation",
            "actions": [
              {
                "name": "subtract",
                "functionRef": {
                  "refName": "subtraction",
                  "arguments": {
                    "leftElement": ".fahrenheit",
                    "rightElement": ".subtractValue"
                  }
                }
              },
              {
                "name": "multiply",
                "functionRef": {
                  "refName": "multiplication",
                  "arguments": {
                     "leftElement": ".difference",
                     "rightElement": ".multiplyValue"
                  }
                }
              }
            ],
            "end": {
              "terminate": true
            }
          }
        ]
      }
      Copy to Clipboard Toggle word wrap

    3. Check the Operation Object section of the OpenAPI specification to understand how to structure parameters in the request.
    4. Use jq expressions to extract data from the payload and map it to the required parameters. Ensure the engine maps parameter names according to the OpenAPI specification.
    5. For operations requiring parameters in the request path instead of the body, refer to the parameter definitions in the OpenAPI specification.

      For more information about mapping parameters in the request path instead of request body, you can refer to the following PetStore API example:

      Example for mapping path parameters

      {
        "/pet/{petId}": {
          "get": {
            "tags": ["pet"],
            "summary": "Find pet by ID",
            "description": "Returns a single pet",
            "operationId": "getPetById",
            "parameters": [
              {
                "name": "petId",
                "in": "path",
                "description": "ID of pet to return",
                "required": true,
                "schema": {
                  "type": "integer",
                  "format": "int64"
                }
              }
            ]
          }
        }
      }
      Copy to Clipboard Toggle word wrap

      Following is an example invocation of a function, in which only one parameter named petId is added in the request path:

      Example of calling the PetStore function

      {
        "name": "CallPetStore", 
      1
      
        "actionMode": "sequential",
        "type": "operation",
        "actions": [
          {
            "name": "getPet",
            "functionRef": {
              "refName": "getPetById", 
      2
      
              "arguments": { 
      3
      
                "petId": ".petId"
              }
            }
          }
        ]
      }
      Copy to Clipboard Toggle word wrap

      1
      State definition, such as CallPetStore.
      2
      Function definition reference. In the previous example, the function definition getPetById is for PetStore OpenAPI specification.
      3
      Arguments definition. OpenShift Serverless Logic adds the argument petId to the request path before sending a request.

After accessing the function definitions in workflow states, you can configure the endpoint URL of OpenAPI services.

Prerequisites

  • You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have created your OpenShift Serverless Logic project.
  • You have access to the OpenAPI specification files.
  • You have defined the function definitions in the workflow.
  • You have the access to the defined functions in the workflow states.

Procedure

  1. Locate the OpenAPI specification file you want to configure. For example, substraction.yaml.
  2. Convert the file name into a valid configuration key by replacing special characters, such as ., with underscores and converting letters to lowercase. For example, change substraction.yaml to substraction_yaml.
  3. To define the configuration key, use the converted file name as the REST client configuration key. Set this key as an environment variable, as shown in the following example:

    quarkus.rest-client.subtraction_yaml.url=http://myserver.com
    Copy to Clipboard Toggle word wrap
  4. To prevent hardcoding URLs in the application.properties file, use environment variable substitution, as shown in the following example:

    quarkus.rest-client.subtraction_yaml.url=${SUBTRACTION_URL:http://myserver.com}
    Copy to Clipboard Toggle word wrap

    In this example:

    • Configuration Key: quarkus.rest-client.subtraction_yaml.url
    • Environment variable: SUBTRACTION_URL
    • Fallback URL: http://myserver.com
  5. Ensure that the (SUBTRACTION_URL) environment variable is set in your system or deployment environment. If the variable is not found, the application uses the fallback URL (http://myserver.com).
  6. Add the configuration key and URL substitution to the application.properties file:

    quarkus.rest-client.subtraction_yaml.url=${SUBTRACTION_URL:http://myserver.com}
    Copy to Clipboard Toggle word wrap
  7. Deploy or restart your application to apply the new configuration settings.

2.2. Configuring OpenAPI services endpoints

OpenShift Serverless Logic uses the kogito.sw.operationIdStrategy property to generate the REST client for invoking services defined in OpenAPI documents. This property determines how the configuration key is derived for the REST client configuration.

The kogito.sw.operationIdStrategy property supports the following values: FILE_NAME, FULL_URI, FUNCTION_NAME, and SPEC_TITLE.

FILE_NAME

OpenShift Serverless Logic uses the OpenAPI document file name to create the configuration key. The key is based on the file name, where special characters are replaced with underscores.

Example configuration:

quarkus.rest-client.stock_portfolio_svc_yaml.url=http://localhost:8282/ 
1
Copy to Clipboard Toggle word wrap

1
The OpenAPI File Path is <project_application_dir>/specs/stock-portfolio-svc.yaml. The generated key that configures the URL for the REST client is stock_portfolio_svc_yaml
FULL_URI

OpenShift Serverless Logic uses the complete URI path of the OpenAPI document as the configuration key. The full URI is sanitized to form the key.

Example for Serverless Workflow

{
    "id": "myworkflow",
    "functions": [
        {
          "name": "myfunction",
          "operation": "https://my.remote.host/apicatalog/apis/123/document"
        }
    ]
    ...
}
Copy to Clipboard Toggle word wrap

Example configuration:

quarkus.rest-client.apicatalog_apis_123_document.url=http://localhost:8282/ 
1
Copy to Clipboard Toggle word wrap

1
The URI path is https://my.remote.host/apicatalog/apis/123/document. The generated key that configures the URL for the REST client is apicatalog_apis_123_document.
FUNCTION_NAME

OpenShift Serverless Logic combines the workflow ID and the function name referencing the OpenAPI document to generate the configuration key.

Example for Serverless Workflow

{
    "id": "myworkflow",
    "functions": [
        {
          "name": "myfunction",
          "operation": "https://my.remote.host/apicatalog/apis/123/document"
        }
    ]
    ...
}
Copy to Clipboard Toggle word wrap

Example configuration:

quarkus.rest-client.myworkflow_myfunction.url=http://localhost:8282/ 
1
Copy to Clipboard Toggle word wrap

1
The workflow ID is myworkflow. The function name is myfunction. The generated key that configures the URL for the REST client is myworkflow_myfunction.
SPEC_TITLE

OpenShift Serverless Logic uses the info.title value from the OpenAPI document to create the configuration key. The title is sanitized to form the key.

Example for OpenAPI document

openapi: 3.0.3
info:
  title: stock-service API
  version: 2.0.0-SNAPSHOT
paths:
  /stock-price/{symbol}:
...
Copy to Clipboard Toggle word wrap

Example configuration:

quarkus.rest-client.stock-service_API.url=http://localhost:8282/ 
1
Copy to Clipboard Toggle word wrap

1
The OpenAPI document title is stock-service API. The generated key that configures the URL for the REST client is stock-service_API.

2.2.1. Using URI alias

As an alternative to the kogito.sw.operationIdStrategy property, you can assign an alias to a URI by using the workflow-uri-definitions custom extension. This alias simplifies the configuration process and can be used as a configuration key in REST client settings and function definitions.

The workflow-uri-definitions extension allows you to map a URI to an alias, which you can reference throughout the workflow and in your configuration files. This approach provides a centralized way to manage URIs and their configurations.

Prerequisites

  • You have access to a OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have access to the OpenAPI specification files.

Procedure

  1. Add the workflow-uri-definitions extension to your workflow. Within this extension, create aliases for your URIs.

    Example workflow

    {
      "extensions": [
        {
          "extensionid": "workflow-uri-definitions", 
    1
    
          "definitions": {
            "remoteCatalog": "https://my.remote.host/apicatalog/apis/123/document" 
    2
    
          }
        }
      ],
      "functions": [ 
    3
    
        {
          "name": "operation1",
          "operation": "remoteCatalog#operation1"
        },
        {
          "name": "operation2",
          "operation": "remoteCatalog#operation2"
        }
      ]
    }
    Copy to Clipboard Toggle word wrap

1
Set the extension ID to workflow-uri-definitions.
2
Set the alias definition by mapping the remoteCatalog alias to a URI, for example, https://my.remote.host/apicatalog/apis/123/document URI.
3
Set the function operations by using the remoteCatalog alias with the operation identifiers, for example, operation1 and operation2 operation identifiers.
  1. In the application.properties file, configure the REST client by using the alias defined in the workflow.

    Example property

    quarkus.rest-client.remoteCatalog.url=http://localhost:8282/
    Copy to Clipboard Toggle word wrap

    In the previous example, the configuration key is set to quarkus.rest-client.remoteCatalog.url, and the URL is set to http://localhost:8282/, which the REST clients use by referring to the remoteCatalog alias.

  2. In your workflow, use the alias when defining functions that operate on the URI.

    Example Workflow (continued):

    {
      "functions": [
        {
          "name": "operation1",
          "operation": "remoteCatalog#operation1"
        },
        {
          "name": "operation2",
          "operation": "remoteCatalog#operation2"
        }
      ]
    }
    Copy to Clipboard Toggle word wrap

2.3. Troubleshooting services

Efficient troubleshooting of the HTTP-based function invocations, such as those using OpenAPI functions, is crucial for maintaining workflow orchestrations.

To diagnose issues, you can trace HTTP requests and responses.

2.3.1. Tracing HTTP requests and responses

OpenShift Serverless Logic uses the Apache HTTP client to the trace HTTP requests and responses.

Prerequisites

  • You have access to an OpenShift Serverless Logic project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
  • You have access to the OpenAPI specification files.
  • You have access to the workflow definition and instance IDs for correlating HTTP requests and responses.
  • You have access to the log configuration of the application where the HTTP service invocations are occurring

Procedure

  1. To trace HTTP requests and responses, OpenShift Serverless Logic uses the Apache HTTP client by setting the following property:

    # Turning HTTP tracing on
    quarkus.log.category."org.apache.http".level=DEBUG
    Copy to Clipboard Toggle word wrap
  2. Add the following configuration to your application’s application.properties file to turn on debugging for the Apache HTTP Client:

    quarkus.log.category."org.apache.http".level=DEBUG
    Copy to Clipboard Toggle word wrap
  3. Restart your application to propagate the log configuration changes.
  4. After restarting, check the logs for HTTP request traces.

    Example logs of a traced HTTP request

    2023-09-25 19:00:55,242 DEBUG Executing request POST /v2/models/yolo-model/infer HTTP/1.1
    2023-09-25 19:00:55,243 DEBUG http-outgoing-0 >> POST /v2/models/yolo-model/infer HTTP/1.1
    2023-09-25 19:00:55,243 DEBUG http-outgoing-0 >> Accept: application/json
    2023-09-25 19:00:55,243 DEBUG http-outgoing-0 >> Content-Type: application/json
    2023-09-25 19:00:55,243 DEBUG http-outgoing-0 >> kogitoprocid: inferencepipeline
    2023-09-25 19:00:55,243 DEBUG http-outgoing-0 >> kogitoprocinstanceid: 85114b2d-9f64-496a-bf1d-d3a0760cde8e
    2023-09-25 19:00:55,243 DEBUG http-outgoing-0 >> kogitoprocist: Active
    2023-09-25 19:00:55,243 DEBUG http-outgoing-0 >> kogitoproctype: SW
    2023-09-25 19:00:55,243 DEBUG http-outgoing-0 >> kogitoprocversion: 1.0
    2023-09-25 19:00:55,243 DEBUG http-outgoing-0 >> Content-Length: 23177723
    2023-09-25 19:00:55,244 DEBUG http-outgoing-0 >> Host: yolo-model-opendatahub-model.apps.trustyai.dzzt.p1.openshiftapps.com
    Copy to Clipboard Toggle word wrap

  5. Check the logs for HTTP response traces following the request logs.

    Example logs of a traced HTTP response

    2023-09-25 19:01:00,738 DEBUG http-outgoing-0 << "HTTP/1.1 500 Internal Server Error[\r][\n]"
    2023-09-25 19:01:00,738 DEBUG http-outgoing-0 << "content-type: application/json[\r][\n]"
    2023-09-25 19:01:00,738 DEBUG http-outgoing-0 << "date: Mon, 25 Sep 2023 19:01:00 GMT[\r][\n]"
    2023-09-25 19:01:00,738 DEBUG http-outgoing-0 << "content-length: 186[\r][\n]"
    2023-09-25 19:01:00,738 DEBUG http-outgoing-0 << "set-cookie: 276e4597d7fcb3b2cba7b5f037eeacf5=5427fafade21f8e7a4ee1fa6c221cf40; path=/; HttpOnly; Secure; SameSite=None[\r][\n]"
    2023-09-25 19:01:00,738 DEBUG http-outgoing-0 << "[\r][\n]"
    2023-09-25 19:01:00,738 DEBUG http-outgoing-0 << "{"code":13, "message":"Failed to load Model due to adapter error: Error calling stat on model file: stat /models/yolo-model__isvc-1295fd6ba9/yolov5s-seg.onnx: no such file or directory"}"
    Copy to Clipboard Toggle word wrap

Chapter 3. Supporting services

3.1. Job service

The Job service schedules and executes tasks in a cloud environment. Independent services implement these tasks, which can be initiated through any of the supported interaction modes, including HTTP calls or Knative Events delivery.

In OpenShift Serverless Logic, the Job service is responsible for controlling the execution of the time-triggered actions. Therefore, all the time-based states that you can use in a workflow, are handled by the interaction between the workflow and the Job service.

For example, every time the workflow execution reaches a state with a configured timeout, a corresponding job is created in the Job service, and when the timeout is met, an HTTP callback is executed to notify the workflow.

The main goal of the Job service is to manage active jobs, such as scheduled jobs that need to be executed. When a job reaches its final state, the Job service removes it. To retain jobs information in a permanent repository, the Job service produces status change events that can be recorded by an external service, such as the Data Index Service.

Note

You do not need to manually install or configure the Job service if you are using the OpenShift Serverless Operator to deploy workflows. The Operator handles these tasks automatically and manages all necessary configurations for each workflow to connect with it.

3.1.1. Job service leader election process

The Job service operates as a singleton service, meaning only one active instance can schedule and execute jobs.

To prevent conflicts when the service is deployed in the cloud, where multiple instances might be running, the Job service supports a leader election process. Only the instance that is elected as the leader manages external communication to receive and schedule jobs.

Non-leader instances remain inactive in a standby state but continue attempting to become the leader through the election process. When a new instance starts, it does not immediately assume leadership. Instead, it enters the leader election process to determine if it can take over the leader role.

If the current leader becomes unresponsive or if it is shut down, another running instance takes over as the leader.

Note

This leader election mechanism uses the underlying persistence backend, which is currently supported only in the PostgreSQL implementation.

3.2. Data Index service

The Data Index service is a dedicated supporting service that stores the data related to the workflow instances and their associated jobs. This service provides a GraphQL endpoint allowing users to query that data.

The Data Index service processes data received through events, which can originate from any workflow or directly from the Job service.

Data Index supports Apache Kafka or Knative Eventing to consume CloudEvents messages from workflows. It indexes and stores this event data in a database, making it accessible through GraphQL. These events provide detailed information about the workflow execution. The Data Index service is central to OpenShift Serverless Logic search, insights, and management capabilities.

The key features of the Data Index service are as follows:

  • A flexible data structure
  • A distributable, cloud-ready format
  • Message-based communication with workflows via Apache Kafka, Knative, and CloudEvents
  • A powerful GraphQL-based querying API
Note

When you are using the OpenShift Serverless Operator to deploy workflows, you do not need to manually install or configure the Data Index service. The Operator automatically manages all the necessary configurations for each workflow to connect with it.

To retrieve data about workflow instances and jobs, you can use GraphQL queries.

3.2.1.1. Retrieve data from workflow instances

You can retrieve information about a specific workflow instance by using the following query example:

{
  ProcessInstances {
    id
    processId
    state
    parentProcessInstanceId
    rootProcessId
    rootProcessInstanceId
    variables
    nodes {
      id
      name
      type
    }
  }
}
Copy to Clipboard Toggle word wrap
3.2.1.2. Retrieve data from jobs

You can retrieve data from a specific job instance by using the following query example:

{
  Jobs {
    id
    status
    priority
    processId
    processInstanceId
    executionCounter
  }
}
Copy to Clipboard Toggle word wrap

You can filter query results by using the where parameter, allowing multiple combinations based on workflow attributes.

Example query to filter by state

{
  ProcessInstances(where: {state: {equal: ACTIVE}}) {
    id
    processId
    processName
    start
    state
    variables
  }
}
Copy to Clipboard Toggle word wrap

Example query to filter by ID

{
  ProcessInstances(where: {id: {equal: "d43a56b6-fb11-4066-b689-d70386b9a375"}}) {
    id
    processId
    processName
    start
    state
    variables
  }
}
Copy to Clipboard Toggle word wrap

By default, filters are combined using the AND Operator. You can modify this behavior by combining filters with the AND or OR operators.

Example query to combine filters with the OR Operator

{
  ProcessInstances(where: {or: {state: {equal: ACTIVE}, rootProcessId: {isNull: false}}}) {
    id
    processId
    processName
    start
    end
    state
  }
}
Copy to Clipboard Toggle word wrap

Example query to combine filters with the AND and OR Operators

{
  ProcessInstances(where: {and: {processId: {equal: "travels"}, or: {state: {equal: ACTIVE}, rootProcessId: {isNull: false}}}}) {
    id
    processId
    processName
    start
    end
    state
  }
}
Copy to Clipboard Toggle word wrap

Depending on the attribute type, you can use the following avaialable Operators:

Expand
Attribute typeAvailable Operators

String array

  • contains: String
  • containsAll: Array of strings
  • containsAny: Array of strings
  • isNull: Boolean (true or false)

String

  • in: Array of strings
  • like: String
  • isNull: Boolean (true or false)
  • equal: String

ID

  • in: Array of strings
  • isNull: Boolean (true or false)
  • equal: String

Boolean

  • isNull: Boolean (true or false)
  • equal: Boolean (true or false)

Numeric

  • in: Array of integers
  • isNull: Boolean
  • equal: Integer
  • greaterThan: Integer
  • greaterThanEqual: Integer
  • lessThan: Integer
  • lessThanEqual: Integer
  • between: Numeric range
  • from: Integer
  • to: Integer

Date

  • isNull: Boolean (true or false)
  • equal: Date time
  • greaterThan: Date time
  • greaterThanEqual: Date time
  • lessThan: Date time
  • lessThanEqual: Date time
  • between: Date range
  • from: Date time
  • to: Date time

You can sort query results based on workflow attributes by using the orderBy parameter. You can also specify the sorting direction in an ascending (ASC) or a descending (DESC) order. Multiple attributes are applied in the order you specified.

Example query to sort by the start time in an ASC order

{
  ProcessInstances(where: {state: {equal: ACTIVE}}, orderBy: {start: ASC}) {
    id
    processId
    processName
    start
    end
    state
  }
}
Copy to Clipboard Toggle word wrap

You can control the number of returned results and specify an offset by using the pagination parameter.

Example query to limit results to 10, starting from offset 0

{
  ProcessInstances(where: {state: {equal: ACTIVE}}, orderBy: {start: ASC}, pagination: {limit: 10, offset: 0}) {
    id
    processId
    processName
    start
    end
    state
  }
}
Copy to Clipboard Toggle word wrap

3.3. Managing supporting services

This section provides an overview of the supporting services essential for OpenShift Serverless Logic. It specifically focuses on configuring and deploying the Data Index service and Job Service supporting services using the OpenShift Serverless Logic Operator.

In a typical OpenShift Serverless Logic installation, you must deploy both services to ensure successful workflow execution. The Data Index service allows for efficient data management, while the Job Service ensures reliable job handling.

When you deploy a supporting service in a given namespace, you can choose between an enabled or disabled deployment. An enabled deployment signals the OpenShift Serverless Logic Operator to automatically intercept workflow deployments using the preview or gitops profile within the namespace and configure them to connect with the service.

For example, when the Data Index service is enabled, workflows are automatically configured to send status change events to it. Similarly, enabling the Job Service ensures that a job is created whenever a workflow requires a timeout. The OpenShift Serverless Logic Operator also configures the Job Service to send events to the Data Index service, facilitating seamless integration between the services.

The OpenShift Serverless Logic Operator does not just deploy supporting services, it also manages other necessary configurations to ensure successful workflow execution. All these configurations are handled automatically. You only need to provide the supporting services configuration in the SonataFlowPlatform CR.

Note

Deploying only one of the supporting services or using a disabled deployment are advanced use cases. In a standard installation, you must enable both services to ensure smooth workflow execution.

To deploy supporting services, configure the dataIndex and jobService subfields within the spec.services section of the SonataFlowPlatform custom resource (CR). This configuration instructs the OpenShift Serverless Logic Operator to deploy each service when the SonataFlowPlatform CR is applied.

Each configuration of a service is handled independently, allowing you to customize these settings alongside other configurations in the SonataFlowPlatform CR.

See the following scaffold example configuration for deploying supporting services:

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform-example
  namespace: example-namespace
spec:
  services:
    dataIndex: 
1

      enabled: true 
2

      # Specific configurations for the Data Index Service
      # might be included here
    jobService: 
3

      enabled: true 
4

      # Specific configurations for the Job Service
      # might be included here
Copy to Clipboard Toggle word wrap
1
Data Index service configuration field.
2
Setting enabled: true deploys the Data Index service. If set to false or omitted, the deployment will be disabled. The default value is false.
3
Job Service configuration field.
4
Setting enabled: true deploys the Job Service. If set to false or omitted, the deployment will be disabled. The default value is false.

3.3.3. Supporting services scope

The SonataFlowPlatform custom resource (CR) enables the deployment of supporting services within a specific namespace. This means all automatically configured supporting services and workflow communications are restricted to the namespace of the deployed platform.

This feature is particularly useful when separate instances of supporting services are required for different sets of workflows. For example, you can deploy an application in isolation with its workflows and supporting services, ensuring they remain independent from other deployments.

The persistence configuration for supporting services in OpenShift Serverless Logic can be either ephemeral or PostgreSQL, depending on needs of your environment. Ephemeral persistence is ideal for development and testing, while PostgreSQL persistence is recommended for production environments.

3.3.4.1. Ephemeral persistence configuration

The ephemeral persistence uses an embedded PostgreSQL database that is dedicated to each service. The OpenShift Serverless Logic Operator recreates this database with every service restart, making it suitable only for development and testing purposes. You do not need any additional configuration other than the following SonataFlowPlatform CR:

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform-example
  namespace: example-namespace
spec:
  services:
    dataIndex:
      enabled: true
      # Specific configurations for the Data Index Service
      # might be included here
    jobService:
      enabled: true
      # Specific configurations for the Job Service
      # might be included here
Copy to Clipboard Toggle word wrap
3.3.4.2. PostgreSQL persistence configuration

For PostgreSQL persistence, you must set up a PostgreSQL server instance on your cluster. The administration of this instance remains independent of the OpenShift Serverless Logic Operator control. To connect a supporting service with the PostgreSQL server, you must configure the appropriate database connection parameters.

You can configure PostgreSQL persistence in the SonataFlowPlatform CR by using the following example:

Example of PostgreSQL persistence configuration

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform-example
  namespace: example-namespace
spec:
  services:
    dataIndex:
      enabled: true
      persistence:
        postgresql:
          serviceRef:
            name: postgres-example 
1

            namespace: postgres-example-namespace 
2

            databaseName: example-database 
3

            databaseSchema: data-index-schema 
4

            port: 1234 
5

          secretRef:
            name: postgres-secrets-example 
6

            userKey: POSTGRESQL_USER 
7

            passwordKey: POSTGRESQL_PASSWORD 
8

    jobService:
      enabled: true
      persistence:
        postgresql:
        # Specific database configuration for the Job Service
        # might be included here.
Copy to Clipboard Toggle word wrap

1
Name of the service to connect with the PostgreSQL database server.
2
Optional: Defines the namespace of the PostgreSQL Service. Defaults to the SonataFlowPlatform namespace.
3
Defines the name of the PostgreSQL database for storing supporting service data.
4
Optional: Specifies the schema for storing supporting service data. Default value is SonataFlowPlatform name, suffixed with -data-index-service or -jobs-service. For example, sonataflow-platform-example-data-index-service.
5
Optional: Port number to connect with the PostgreSQL Service. Default value is 5432.
6
Defines the name of the secret containing the username and password for database access.
7
Defines the name of the key in the secret that contains the username to connect with the database.
8
Defines the name of the key in the secret that contains the password to connect with the database.
Note

You can configure each service’s persistence independently by using the respective persistence field.

Create the secrets to access PostgreSQL by running the following command:

$ oc create secret generic <postgresql_secret_name> \
  --from-literal=POSTGRESQL_USER=<user> \
  --from-literal=POSTGRESQL_PASSWORD=<password> \
  -n <namespace>
Copy to Clipboard Toggle word wrap

The OpenShift Serverless Logic Operator automatically connects supporting services to the common PostgreSQL server configured in the spec.persistence field.

For rules, the following precedence is applicable:

  • If you configure a specific persistence for a supporting service, for example, services.dataIndex.persistence, it uses that configuration.
  • If you do not configure persistence for a service, the system uses the common persistence configuration from the current platform.
Note

When using a common PostgreSQL configuration, each service schema is automatically set as the SonataFlowPlatform name, suffixed with -data-index-service or -jobs-service, for example, sonataflow-platform-example-data-index-service.

3.3.5. Advanced supporting services configurations

In scenarios where you must apply advanced configurations for supporting services, use the podTemplate field in the SonataFlowPlatform custom resource (CR). This field allows you to customize the service pod deployment by specifying configurations like the number of replicas, environment variables, container images, and initialization options.

You can configure advanced settings for the service by using the following example:

Advanced configurations example for the Data Index service

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform-example
  namespace: example-namespace
spec:
  services:
    # This can be either 'dataIndex' or 'jobService'
    dataIndex:
      enabled: true
      podTemplate:
        replicas: 2 
1

        container: 
2

          env: 
3

            - name: <any_advanced_config_property>
              value: <any_value>
          image: 
4

        initContainers: 
5
Copy to Clipboard Toggle word wrap

Note

You can set the 'services' field to either 'dataIndex' or 'jobService' depending on your requirement. The rest of the configuration remains the same.

1
Defines the number of replicas. Default value is 1. In the case of jobService, this value is always overridden to 1 because it operates as a singleton service.
2
Holds specific configurations for the container running the service.
3
Allows you to fine-tune service properties by specifying environment variables.
4
Configures the container image for the service, useful if you need to update or customize the image.
5
Configures init containers for the pod, useful for setting up prerequisites before the main container starts.
Note

The podTemplate field provides flexibility for tailoring the deployment of each supporting service. It follows the standard PodSpec API, meaning the same API validation rules apply to these fields.

3.3.6. Cluster scoped supporting services

You can define a cluster-wide set of supporting services that can be consumed by workflows across different namespaces, by using the SonataFlowClusterPlatform custom resource (CR). By referencing an existing namespace-specific SonataFlowPlatform CR, you can extend the use of these services cluster-wide.

You can use the following example of a basic configuration that enables workflows deployed in any namespace to utilize supporting services deployed in a specific namespace, such as example-namespace:

Example of a SonataFlowClusterPlatform CR

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowClusterPlatform
metadata:
  name: cluster-platform
spec:
  platformRef:
    name: sonataflow-platform-example 
1

    namespace: example-namespace 
2
Copy to Clipboard Toggle word wrap

1
Specifies the name of the already installed SonataFlowPlatform CR that manages the supporting services.
2
Specifies the namespace of the SonataFlowPlatform CR that manages the supporting services.
Note

You can override these cluster-wide services within any namespace by configuring that namespace in SonataFlowPlatform.spec.services.

Legal Notice

Copyright © 2025 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat
Back to top