Creating and running workflow projects using KN CLI and Visual Studio Code

This guide showcases using the Knative Workflow CLI plugin and Visual Studio code to create & run Kogito Serverless Workflow projects.

Prerequisites
Preparing your environment
  • Install Docker or Podman.

  • Install minikube.

  • Install kubectl.

  • Start minikube. Depending on your environment, set --driver flag to podman or docker

minikube start --cpus 4 --memory 8096 --addons registry --addons metrics-server --insecure-registry "10.0.0.0/24" --insecure-registry "localhost:5000"  --driver=docker

Creating a workflow project with Visual Studio Code and KN CLI

Use the create command with kn workflow to scaffold a new SonataFlow project.

  • Navigate to you development directory and create your project.

kn workflow create -n my-sonataflow-project
  • This will create a folder with name my-sonataflow-project and a sample workflow workflow.sw.json

cd ./my-sonataflow-project
  • Open the folder in Visual Studo Code and examine the created workflow.sw.json using our extension.

Now you can run the project and execute the workflow.

Running a Workflow project with Visual Studio Code and KN CLI

Use the run command with kn workflow to build and run the Kogito Serverless Workflow project in local development mode.

  • Run the project.

kn workflow run
  • The Development UI wil be accesible at localhost:8080/q/dev

  • You can now work on your project. Any changes will be picked up by the hot reload feature.

  • See Workflow instances guide on how to run workflows via Development UI.

  • Once you are done developing your project navigate to the terminal that is running the kn workflow run command and hit Ctlr+C to stop the development environment.

To deploy the finished project to a local cluster, proceed to the next section.

Deploying a workflow project with Visual Studio Code and KN CLI

Use the deploy command with kn workflow to deploy the Kogito Serverless Workflow project into your local cluster.

  • Deploy to minikube

kn workflow deploy
  • (Optional) Using k9scli you can examine your deployment.

  • In a different bash instance, create a port mapping:

minikube service hello --namespace default --url
  • Use this URL to access your workflow instances using the Developer UI

    • <RETURNED_URL>/q/dev/org.kie.kogito.kogito-quarkus-serverless-workflow-devui/workflowInstances

  • To update the image run the deploy again, note that this may take some time.

  • To stop the deployment, use the undeploy command:

kn worklow undeploy
  • You can validate your pod is terminating using k9s cli.

Testing your workflow application

To test your workflow application you can use any capable REST client out there. All that is needeed is the URL of your deployed worklow project.

Prerequisites
Testing your workflow application
  • To test your workflow project, access the Swagger UI on <URL>/q/swagger-ui to examine available endpoints.

  • In order to execute the workflow once, run:

curl -X 'POST' \
  '<URL>/hello' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "workflowdata": {}
}'
  • To examine executed instance you can use the GraphQL UI by navigating to <URL>/q/graphl-ui.

Found an issue?

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