Building and Deploying Workflows with the Operator

This document describes how to build and deploy your workflow on a Kubernetes cluster using the Kogito Serverless Workflow Operator only by having a workflow definition.

Kogito Serverless Workflow Operator is under active development with features yet to be implemented. Please see Kogito Serverless Workflow Operator Known Issues, Limitations and Roadmap.

Prerequisites

Preparing for the build

You should follow these steps to create a container that you can deploy as a service on Kubernetes.

Create a namespace for the building phase

Create a new namespace that will hold all the resources that the operator will create (pods, deployments, services, secretes, config map, and Custom Resources) in this guide.

Create a namespace for the application to build & run in
kubectl create namespace kogito-workflows
# set the kogito-workflows namespace to your context
kubectl config set-context --current --namespace=kogito-workflows

Create a secret for the container registry authentication

Create a secret for the container registry authentication
kubectl create secret docker-registry regcred --docker-server=<registry_url> --docker-username=<registry_username> --docker-password=<registry_password> --docker-email=<registry_email> -n kogito-workflows

or you can directly import your local docker config into your Kubernetes cluster:

Create a secret for the container registry authentication based on local docker config
kubectl create secret generic regcred --from-file=.dockerconfigjson=${HOME}/.docker/config.json --type=kubernetes.io/dockerconfigjson -n kogito-workflows

Double check your ${HOME}/.docker/config.json. If you’re using local desktop authentication, this configuration won’t work in the cluster. You can initialize this by logging in in the target registry, e.g. docker login.

Configure the Kogito Serverless Workflow Operator (i.e. registry address, secret) for building your workflows

The KogitoServerlessPlatform is the resource used to control the behavior of the Kogito Serverless Workflow Operator. It defines the behavior of all Custom Resources (Workflow and Build) in the given namespace.

Since the operator is installed in global mode, you will need to specify a platform in each namespace where you want to deploy workflows. You can find a basic KogitoServerlessPlatform custom resource example in the config/samples folder that you can simply apply to configure your operator.

Create a KogitoServerlessPlatform
kubectl apply -f https://raw.githubusercontent.com/kiegroup/kogito-serverless-operator/main/config/samples/sw.kogito_v1alpha08_kogitoserverlessplatform.yaml -n kogito-workflows

In this Custom Resource, spec.platform.registry.secret is the name of the secret you created just before.

You can also update "on-the-fly" the KogitoServerlessPlatform registry field with this command (change <YOUR_REGISTRY>)

Create a KogitoServerlessPlatform with a specific registry
curl https://raw.githubusercontent.com/kiegroup/kogito-serverless-operator/main/config/samples/sw.kogito_v1alpha08_kogitoserverlessplatform.yaml | sed "s|address: .*|address: <YOUR_REGISTRY>" | kubectl apply -f -

In order to retrieve the Cluster IP address of Minikube’s internal registry to configure your platform, you can use the following command:

Retrieve Minikube registry internal IP
kubectl get svc registry -n kube-system -ojsonpath='{.spec.clusterIP}'

Build and deploy your workflow application

You can now send your workflow definition (KogitoServerlessWorkflow) to the operator.

You can find a basic KogitoServerlessWorkflow in the config/samples folder that is defining the Kogito Serverless Workflow Greeting example.

kubectl apply -f https://raw.githubusercontent.com/kiegroup/kogito-serverless-operator/main/config/samples/sw.kogito_v1alpha08_kogitoserverlessworkflow.yaml -n kogito-workflows

You can check the logs of the build of your workflow via:

Get the workflow application pod logs
kubectl logs kogito-greeting-builder -n kogito-workflows

The final pushed image must be printed into the logs at the end of the build.

Check the workflow application is running

In order to check that the Kogito Serverless Workflow Greeting application is up and running, you can try to perform a test HTTP call, from the greeting pod.

Check the greeting application is running
kubectl patch svc greeting -n kogito-workflows -p '{"spec": {"type": "NodePort"}}'
GREETING_SVC=$(minikube service greeting -n kogito-workflows --url)
curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"name": "John", "language": "English"}' $GREETING_SVC/greeting

If everything is working well you should receive a response like this:

Response from the greeting application
{"id":"b5fbfaa3-b125-4e6c-9311-fe5a3577efdd","workflowdata":{"name":"John","language":"English","greeting":"Hello from JSON Workflow, "}}

Found an issue?

If you find an issue or any misleading information, please feel free to report it here. We really appreciate it!