Deploying your SonataFlow application on Minikube
This document describes how to deploy your workflow application using a local Kubernetes cluster, such as Minikube, along with a procedure to run the Knative platform.
For more information about Minikube and related system requirements, see Getting started with Minikube documentation.
-
Your SonataFlow application is ready to use.
For more information about building the application container, see Building workflow images using Quarkus CLI. -
Minikube is installed
-
kubectl
command-line tool is installed. Otherwise, Minikube handles it. -
Knative CLI is installed.
For more information, see Install the Knative CLI. -
Knative workflow CLI is installed.
For more information see Serverless Workflow plug-in for Knative CLI. -
(Optional) Quarkus CLI is installed.
For more information, see Building Quarkus Apps with Quarkus command line interface (CLI).
To deploy your workflow application on Minikube, you need to install Knative on Minikube. However, first you need to ensure that Minikube is installed correctly.
You can check the Minikube installation by entering the following commands in a command terminal:
minikube version
kn version
kubectl
CLI versionkubectl version
If kubectl is available using Minikube
|
Installing Knative on Minikube
Once you verify the Minikube and Knative CLI installation, you can install Knative on Minikube.
-
Minikube is installed.
-
Knative CLI is installed.
For more information, see Install the Knative CLI.
-
Open a command terminal and install Knative on Minikube.
-
Configure Knative on Minikube.
Knative CLI offers
quickstart
plug-in, which provides the required configurations. For information about installing thequickstart
plug-in, see Install Knative using quickstart. -
After configuring the plug-in, execute the following command to configure a Minikube profile:
Configure a Minikube profilekn quickstart minikube
The previous command configures a Minikube profile called
knative
. After creating a Minikube profile, all Minikube commands use the created profile. -
To list the available Minikube profiles, enter the following command:
List the available Minikube profilesminikube profile list
-
Enter the following command to open the Minikube web console on the
knative
profile:Open Minikube web consoleminikube dashboard --profile knative
The previous command opens the Kubernetes Management console in your browser. If the console is not opened, you can go to the URL that is returned.
To follow the manual process of installing Knative on Minikube, see Knative tutorial on Minikube. |
Deploying your workflow application on Minikube
Once you install Knative on Minikube, you can initiate the process of deploying your workflow application on Minikube.
-
Minikube is installed.
-
Knative is ready.
For more information, see Installing Knative on Minikube. -
Knative CLI is installed.
-
(Optional) Quarkus CLI is installed.
For more information, see Building Quarkus Apps with Quarkus command line interface (CLI). -
Your SonataFlow application is ready to use.
-
In a command terminal, enter the following command to configure Docker to use the in-cluster Docker daemon:
Configure Docker to use in-cluster Docker Daemoneval $(minikube -p minikube docker-env --profile knative)
-
Build your application to store it in the Minikube registry.
If your workflow application container image is built before configuring Docker to use the in-cluster Docker daemon, then you might need to build the image again so that the image is available in the Minikube registry.
If you are building native container images, ensure that you use the following system property to use Minikube Docker Daemon:
System property to build container images-Dquarkus.native.remote-container-build=true
You might be required to tag the container images using one of the following registry:
-
ko.local
-
dev.local
For more information, see How to use locally built docker image.
In that case, use the
-Dquarkus.container-image.registry=some_of_the_values_above
property to enable Knative fetch the container images from Minikube Docker Daemon.If you do not use the values, you might need to set the
imagePullPolicy
toNever
orIfNotPresent
, otherwise, Minikube pulls the images from a remote registry. This behavior can be avoided by tagging the image using previously listed domains. -
-
In a separate command terminal window, start the Minikube tunnel using the Knative profile to prepare the environment:
Start Minikube tunnel using Knative profileminikube tunnel --profile knative
The previous command starts in a loop. Therefore, this command must be running throughout the process mentioned in this document. On Mac and Windows, you might be required to provide the user password.
Example tunnel outputStatus: machine: knative pid: 124859 route: 10.96.0.0/12 -> 192.168.58.2 minikube: Running services: [kourier] errors: minikube: no errors router: no errors loadbalancer emulator: no errors
-
After starting the Minikube tunnel, create
serverless-workflow-greeting-quarkus
namespace using the following command:Create namespacekubectl create namespace serverless-workflow-greeting-quarkus
-
Set the Kubernetes context to the newly created namespace using the following command:
Set Kubernetes context to a namespacekubectl config set-context --current --namespace=serverless-workflow-greeting-quarkus
After setting the context, all kubectl commands will use the selected namespace.
You can use the following command to verify the current namespace:Verify the current namespacekubectl config view --minify -o jsonpath='{..namespace}'
-
Deploy your SonataFlow application using the Minikube registry.
The next step is to deploy your workflow application and execute it. You can read the further sections on the different procedures to deploy your SonataFlow application.
You can use the native image due to the faster startup.
In the following procedures, you can find different approaches to deploy your workflow application, such as:
Deploying your workflow application using Knative CLI
Once you have pushed your workflow application into the Minikube’s registry, you can use the command-line tools, such as Knative CLI or Kubernetes CLI
to initiate the deployment process.
-
Workflow application is installed.
-
Knative CLI is installed.
For more information, see Install the Knative CLI.
-
In a command terminal, execute the following command to deploy your workflow application using Knative CLI:
Example of deploying workflow application using Knative CLIkn service create hello-workflow \ --image=dev.local/kogito/serverless-workflow-greeting-quarkus:1.0 \ --pull-policy=IfNotPresent \ --port 8080
Example outputCreating service 'hello-workflow' in namespace 'serverless-workflow-greeting-quarkus': 0.066s The Route is still working to reflect the latest desired specification. 0.099s ... 0.322s Configuration "hello-workflow" is waiting for a Revision to become ready. 4.885s ... 5.061s Ingress has not yet been reconciled. 5.322s Waiting for load balancer to be ready 5.460s Ready to serve. Service 'hello-workflow' created to latest revision 'hello-workflow-00001' is available at URL: http://hello-workflow.serverless-workflow-greeting-quarkus.10.103.94.37.sslip.io
Depending on the cluster type where you have deployed the workflow application, the service URL might be different. Pay attention to the output to use the correct URL in the next topic. |
Verify if the workflow application is deployed correctly:
NAME URL LATEST AGE CONDITIONS READY REASON
hello-workflow http://hello-workflow.serverless-workflow-greeting-quarkus.10.103.94.37.sslip.io hello-workflow-00001 7m6s 3 OK / 3 True
curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"name": "John", "language": "English"}' http://hello-workflow.serverless-workflow-greeting-quarkus.10.103.94.37.sslip.io/jsongreet
{"id":"0f77abce-837e-4bd2-b4f1-a0e5e0265fcb","workflowdata":{"name":"John","language":"English","greeting":"Hello from JSON Workflow, "}}
Deploying your workflow application using Kubernetes CLI
You can also use kubectl
command-line interface and plain Kubernetes objects to deploy your workflow application.
And, instead of creating knative
yaml|json
descriptors, you can leverage the Quarkus Kubernetes extension and Kogito Knative add-on to generate the descriptors.
-
Kogito Workflow application ready to use.
-
Kubernetes CLI
command-line tool is installed. -
(Optional) Quarkus CLI is installed
For more information about installing the Quarkus CLI, see Installing the Quarkus CLI.
-
Add the Quarkus extensions to generate
knative
yaml|json
descriptors.To use the Quarkus Kubernetes extension and Kogito Knative add-on, ensure that the following dependencies are available in the
pom.xml
file and Gradle:<dependency> <groupId>org.kie.kogito</groupId> <artifactId>kogito-addons-quarkus-knative-eventing</artifactId> </dependency> <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-kubernetes</artifactId> </dependency>
quarkus-kubernetes 'io.quarkus:quarkus-kubernetes:2.16.9.Final' quarkus-kubernetes 'org.kie.kogito:kogito-addons-quarkus-knative-eventing:1.43.0.Final'
quarkus ext add org.kie.kogito:kogito-addons-quarkus-knative-eventing quarkus-openshift1.43.0.Final'
-
To generate the
knative
yaml|json
descriptors, set the following properties in theapplication.properties
file of your workflow application:System properties to generate knative descriptorsquarkus.kubernetes.deployment-target=knative quarkus.knative.name=hello-workflow
-
Build your workflow application.
Once you have built your application, you can find the generated descriptors files in the
target/kubernetes
directory:-
knative.json
-
knative.yml
The image used in this section is the one built in the following guide: Build Workflow Image with Quarkus CLI.
Following is an example of the generated files:
Knative descriptor example for a workflow application--- apiVersion: serving.knative.dev/v1 kind: Service metadata: annotations: app.quarkus.io/commit-id: 06c3fe8e2dfc42e2211cbcc41224f5a3d6bd1f26 app.quarkus.io/build-timestamp: 2022-06-23 - 23:53:38 +0000 labels: app.kubernetes.io/name: hello-workflow name: hello-workflow spec: template: metadata: labels: app.kubernetes.io/name: hello-workflow spec: containerConcurrency: 0 containers: - image: dev.local/kogito/serverless-workflow-greeting-quarkus:1.0-native livenessProbe: failureThreshold: 3 httpGet: path: /q/health/live port: null scheme: HTTP initialDelaySeconds: 0 periodSeconds: 30 successThreshold: 1 timeoutSeconds: 10 name: hello-workflow ports: - containerPort: 8080 name: http1 protocol: TCP readinessProbe: failureThreshold: 3 httpGet: path: /q/health/ready port: null scheme: HTTP initialDelaySeconds: 0 periodSeconds: 30 successThreshold: 1 timeoutSeconds: 10
Once the files are generated, you must add the
imagePullPolicy
manually before deploying the workflow application. -
-
Enter the following command to deploy the workflow application using
kubectl
:Deploy the workflow application usingkubectl
kubectl apply -f target/kubernetes/knative.yml
Verify if the workflow application is deployed correctly:
NAME URL LATEST AGE CONDITIONS READY REASON
hello-workflow http://hello-workflow.serverless-workflow-greeting-quarkus.10.103.94.37.sslip.io hello-workflow-00001 7m6s 3 OK / 3 True
curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"name": "John", "language": "English"}' http://hello-workflow.serverless-workflow-greeting-quarkus.10.103.94.37.sslip.io/jsongreet
{"id":"0f77abce-837e-4bd2-b4f1-a0e5e0265fcb","workflowdata":{"name":"John","language":"English","greeting":"Hello from JSON Workflow, "}}
Deploying your workflow application using Quarkus CLI
-
Workflow application is ready.
-
Quarkus CLI is installed.
For more information, see Building Quarkus Apps with Quarkus command line interface (CLI).
-
Add the Quarkus extensions to deploy the
knative
service.You can add the Kubernetes and the Kogito Knative extensions to your project with the Quarkus CLI:
Add Kubernetes and Kogito Knative extensions to the project with Quarkus CLIquarkus ext add quarkus-kubernetes kogito-addons-quarkus-knative-eventing
-
To deploy the workflow application using Quarkus CLI, set the following system properties in
application.properties
file:Required system propertiesquarkus.knative.name=hello-workflow (1) quarkus.kubernetes.deployment-target=knative (2) quarkus.kubernetes.deploy=true (3) quarkus.container-image.push=false (4) quarkus.container-image.group=kogito (5) quarkus.container-image.registry=dev.local (6) quarkus.container-image.tag=1.0-SNAPSHOT (7)
1 Property to set the Knative service name 2 Property to set the target deployment type 3 Property to set whether or not deploy on an active Kubernetes cluster 4 Property to whether or not push images. False when using Minikube’s remote Docker daemon to avoid image validation 5 Property to define which registry group/namespace the built image belongs to 6 Property to define to which registry the built image will be pushed to 7 Sets the built Container Image tag This feature works with Quarkus 2.10.2.Final or later. For more information, see link.
quarkus build -DskipTests
The |
Verify if the workflow application is deployed correctly:
NAME URL LATEST AGE CONDITIONS READY REASON
hello-workflow http://hello-workflow.serverless-workflow-greeting-quarkus.10.103.94.37.sslip.io hello-workflow-00001 7m6s 3 OK / 3 True
curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"name": "John", "language": "English"}' http://hello-workflow.serverless-workflow-greeting-quarkus.10.103.94.37.sslip.io/jsongreet
{"id":"0f77abce-837e-4bd2-b4f1-a0e5e0265fcb","workflowdata":{"name":"John","language":"English","greeting":"Hello from JSON Workflow, "}}
Verify if the workflow application is deployed correctly:
NAME URL LATEST AGE CONDITIONS READY REASON
hello-workflow http://hello-workflow.serverless-workflow-greeting-quarkus.10.103.94.37.sslip.io hello-workflow-00001 7m6s 3 OK / 3 True
curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"name": "John", "language": "English"}' http://hello-workflow.serverless-workflow-greeting-quarkus.10.103.94.37.sslip.io/jsongreet
{"id":"0f77abce-837e-4bd2-b4f1-a0e5e0265fcb","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!