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. |
-
A workflow definition.
-
The Kogito Serverless Workflow Operator installed. See Install the Kogito Serverless Workflow Operator
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.
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
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:
kubectl create secret generic regcred --from-file=.dockerconfigjson=${HOME}/.docker/config.json --type=kubernetes.io/dockerconfigjson -n kogito-workflows
Double check your |
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.
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, |
You can also update "on-the-fly" the KogitoServerlessPlatform
registry field with this command (change <YOUR_REGISTRY>)
KogitoServerlessPlatform
with a specific registrycurl 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:
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:
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.
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:
{"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!