Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Function and event orchestration with OpenShift serverless logic

Now generally available in OpenShift Serverless 1.33

October 9, 2024
Kris Verlaenen Ricardo Zanini
Related topics:
Developer ToolsEvent-DrivenMicroservicesServerless
Related products:
Red Hat OpenShift Serverless

Share:

    Cloud-native applications are often composed of different services and can communicate in an event-driven manner. Red Hat OpenShift Serverless already enables developers to easily create and deploy stateless functions, and supports event-driven communication through eventing. 

    With serverless logic, you can now also define and deploy workflows to orchestrate functions, events, and other services. Not only does this give developers a declarative way to build applications using workflows (YAML or JSON format), it also provides the necessary features, services, and tools to simplify development, deployment, and runtime management. Serverless logic has now reached general availability in OpenShift Serverless 1.33.

    A first look

    If you're wondering what this looks like: Imagine you want to build a small application that automatically processes subscription events by invoking the subscription service to register the user. A workflow to automatically do this would only contain two steps:

    • One to listen for the event (3).
    • Followed by an invocation of the function to register the subscription (4) with the right arguments from the event (5).

    Events (1) and functions (2) are defined upfront by referencing their definition (for example, using OpenAPI), so that the framework can know where to find them and generate code to invoke them:

    {
      "id": "SubscriptionWorkflow",
      "version": "1.0",
      "specVersion": "0.8",
      "name": "Subscription Workflow",
      "description": "Registering subscriptions upon an event",
      "start": "Receive Subscription",
      "events": [ (1)
        {
          "type": "newSubscription",
          "name": "NewSubscriptionEvent"
        }
      ],
      "functions": [ (2)
        {
          "name": "registerSubscriptionFunction",
          "operation": "subscription.openapi.json#register"
        }
      ],
      "states": [
        {
          "name": "Receive Subscription", (3)
          "type": "event",
          "onEvents": [
            {
              "eventRefs": ["NewSubscriptionEvent"]
            }
          ],
          "transition": "Register Subscription"
        },
        {
          "name": "Register Subscription", (4)
          "type": "operation",
          "actions": [
            {
              "name": "registerSubscription",
              "functionRef": {
                "refName": "registerSubscriptionFunction",
                "arguments": { (5)
                  "name": "$.event.name",
                  "email": "$.event.email"
                }
              }
            }
          ],
          "end": true
        }
      ]
    } 

    Figure 1 depicts this workflow.

    Graphical visualization of the workflow
    Graphical visualization
    Created by Kris Verlaenen,
    Figure 1: Graphical visualization of the workflow.

    Note that this is a very simple example to get you started. A more elaborate example could, for instance, include email verification by waiting for a confirmation email with a specified timeout. (You should configure your Maven project to Red Hat build of Quarkus and OpenShift serverless logic first, as explained in this chapter.)

    Serverless workflow specification

    Serverless logic uses the Serverless Workflow Specification to define these orchestrations. Serverless Workflow is a vendor-neutral, open-source standard for defining workflows, at the Cloud Native Computing Foundation (CNCF).

    The specification not only provides building blocks for events (incoming and outgoing) and function invocations (either synchronously or with a callback) as already seen to some extent in the previous example, but it also offers easy to use constructs for a lot of common patterns. This includes switches or parallel branches, input and output mapping, timeouts, error management and compensation for each, and more. All these constructs allow developers to build workflows that orchestrate any number of functions, services and/or events. 

    Focus on developer efficiency and insights

    To be able to execute these workflows, serverless logic leverages SonataFlow, an open source serverless workflow runtime, upstream part of the Apache KIE incubator project.

    SonataFlow is a serverless workflow implementation based on a generic cloud-native workflow engine. As a result, it offers the ability to automatically generate a lightweight workflow service for your workflow(s), with fast startup time and integration with many other cloud-native technologies. This runtime supports stable, scalable execution of your workflow(s) using generated remote REST interfaces, with (optional) support for persistence, timers, monitoring, auditing, and many more capabilities (leveraging the underlying Quarkus platform for their implementation). 

    To empower developers, serverless logic offers more than just a runtime:

    • The OpenShift serverless logic Operator, in combination with the kn-workflow command line interface (CLI), allows you to create a workflow project, run it, and deploy the workflow into your cloud environment. Through a simple CLI command you can submit a Custom Resource (CR) containing the workflow (and potentially some supporting files) and the Operator will deploy a workflow runtime for you (supporting both a developer profile using a prebuilt image or a production profile building a custom immutable image).
    • Creating workflows is a lot easier with the right tooling support, in this case by offering a VSCode extension that offers validation, code completion, graphical visualization, and more.
    • Workflows can become complex, and developers need help and insights (based on audit information collected by the runtime), both during the development cycle or when monitoring workflows at runtime. The runtime console gives a detailed view of the status of all your workflow instances.

    Benefits

    By extending the developer’s toolbox with workflows, developers can spend less time writing code hooking services together, but instead can leverage higher-level workflow building blocks to build applications. The simplified experience hides a lot of the underlying complexity (related to state persistence, audit, timers, and etc.) and instead focuses on providing domain-level insights into the status of your application workflows.

    How to get started with serverless logic

    Head to the OpenShift documentation for instructions on how to get started. After installing the kn-workflow CLI, you can use it to create and run your workflows. Typically developers can implement and test their workflows locally, on their laptop, before deploying them in the cloud using the Operator.

    To get your first workflow running locally, all you need is the following commands:

    kn-workflow create --name my-project
    kn-workflow run

    The second command (to be executed in your project folder in the first step) will start a workflow service (using Podman/Docker) for the workflow in your project. You can immediately access the runtime tools on this service to start your workflow or look at the status of running instances. The following video shows the getting started experience.

    Figure 2: Video showing the Serverless Logic getting started experience.

    Conclusion

    If you made it this far, congratulations! You are now ready to update the workflow according to your own needs, using all the building blocks at your disposal to orchestrate your services and/or events. Not finding what you’re looking for? There are a lot more guides and examples available.

    If you want to take a quick look, you can also access our online playground start.kubesmarts.org (running completely in your browser) for a quick first look at the tooling and some examples (Figure 3).

    Online playground at start.kubesmarts.org
    Online playground at start.kubesmarts.org
    Figure 3: Online playground at start.kubesmarts.org.

    Related Posts

    • Deploying serverless Node.js applications on Red Hat OpenShift, Part 1

    • Serverless applications made faster and simpler with OpenShift Serverless GA

    • How OpenShift Serverless Logic evolved to improve workflows

    • Create your first serverless function with Red Hat OpenShift Serverless Functions

    • How OpenShift Serverless Logic evolved to improve workflows

    Recent Posts

    • Storage considerations for OpenShift Virtualization

    • Upgrade from OpenShift Service Mesh 2.6 to 3.0 with Kiali

    • EE Builder with Ansible Automation Platform on OpenShift

    • How to debug confidential containers securely

    • Announcing self-service access to Red Hat Enterprise Linux for Business Developers

    What’s up next?

     Learn how to implement a back-end function and a front-end web application, then use a Function as a Service (FaaS) object to process data.

    Start the activity
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue