diff --git a/serverlessworkflow/antora.yml b/serverlessworkflow/antora.yml index eb283e70b4..c2f8c86857 100644 --- a/serverlessworkflow/antora.yml +++ b/serverlessworkflow/antora.yml @@ -109,6 +109,7 @@ asciidoc: kaoto_url: https://marketplace.visualstudio.com/items?itemName=redhat.vscode-kaoto minikube_url: https://minikube.sigs.k8s.io kogito_serverless_operator_url: https://github.com/apache/incubator-kie-kogito-serverless-operator/ + flow_examples_operator_url: https://github.com/flows-examples/techpreview2/ docs_issues_url: https://github.com/apache/incubator-kie-kogito-docs/issues/new ocp_local_url: https://access.redhat.com/documentation/en-us/red_hat_openshift_local/2.17 ocp_knative_serving_url: https://docs.openshift.com/container-platform/4.12/serverless/install/installing-knative-serving.html diff --git a/serverlessworkflow/modules/ROOT/nav.adoc b/serverlessworkflow/modules/ROOT/nav.adoc index 7429f9d6fb..1f8a3db4c5 100644 --- a/serverlessworkflow/modules/ROOT/nav.adoc +++ b/serverlessworkflow/modules/ROOT/nav.adoc @@ -111,6 +111,9 @@ ** xref:data-index/data-index-core-concepts.adoc[Core concepts] ** xref:data-index/data-index-service.adoc[Standalone service] ** xref:data-index/data-index-quarkus-extension.adoc[Quarkus Extension] +** Operator +*** xref:data-index/data-index-usecase-singleton.adoc[] +*** xref:data-index/data-index-usecase-multi.adoc[] //** Quarkus Extensions TODO: https://issues.redhat.com/browse/KOGITO-9463 * Use Cases ** xref:use-cases/orchestration-based-saga-pattern.adoc[Saga Orchestration] diff --git a/serverlessworkflow/modules/ROOT/pages/data-index/common/_prerequisites.adoc b/serverlessworkflow/modules/ROOT/pages/data-index/common/_prerequisites.adoc new file mode 100644 index 0000000000..80b3418e1b --- /dev/null +++ b/serverlessworkflow/modules/ROOT/pages/data-index/common/_prerequisites.adoc @@ -0,0 +1,28 @@ + +.Prerequisites +* Minikube installed with `registry` addon enabled +* `kubectl` {kubectl_prereq} +* SonataFlow operator installed if workflows are deployed. To install the operator you can see xref:cloud/operator/install-serverless-operator.adoc[]. + +[NOTE] +==== +We recommend that you start Minikube with the following parameters, note that the `registry` addon must be enabled. + +[source,shell] +---- +minikube start --cpus 4 --memory 10240 --addons registry --addons metrics-server --insecure-registry "10.0.0.0/24" --insecure-registry "localhost:5000" +---- + +To verify that the registry addon was property added you can execute this command: + +[source,shell] +---- +minikube addons list | grep registry +---- + +---- +| registry | minikube | enabled ✅ | Google | +| registry-aliases | minikube | disabled | 3rd party (unknown) | +| registry-creds | minikube | disabled | 3rd party (UPMC Enterprises) | +---- +==== \ No newline at end of file diff --git a/serverlessworkflow/modules/ROOT/pages/data-index/common/_querying_dataindex.adoc b/serverlessworkflow/modules/ROOT/pages/data-index/common/_querying_dataindex.adoc new file mode 100644 index 0000000000..7effdb6fe5 --- /dev/null +++ b/serverlessworkflow/modules/ROOT/pages/data-index/common/_querying_dataindex.adoc @@ -0,0 +1,105 @@ +[[querying-dataindex-minikube]] +== Querying Data Index service on Minikube + +You can use the public Data Index endpoint to play around with the GraphiQL interface. + +.Procedure +This procedure apply to all use cases with that deploys the Data Index Service. + +* Get the Data Index Url: +[source,shell] +---- +minikube service data-index-service-postgresql --url -n my_usecase +---- + +* Open the GrahiqlUI + +Using the url returned, open a browser window in the following url http://192.168.49.2:32409/graphiql/, + +[NOTE] +==== +that IP and port will be different in your installation, and don't forget to add the last slash "/" to the url, otherwise the GraphiqlUI won't be opened. +==== + + +To see the process instances information you can execute this query: + +[source,shell] +---- +{ + ProcessInstances { + id, + processId, + processName, + variables, + state, + endpoint, + serviceUrl, + start, + end + } +} +---- + +The results should be something like: + +[source] +---- +{ + "data": { + "ProcessInstances": [ + { + "id": "3ed8bf63-85c9-425d-9099-49bfb63608cb", + "processId": "greeting", + "processName": "workflow", + "variables": "{\"workflowdata\":{\"name\":\"John\",\"greeting\":\"Hello from JSON Workflow, \",\"language\":\"English\"}}", + "state": "COMPLETED", + "endpoint": "/greeting", + "serviceUrl": "http://greeting", + "start": "2023-09-13T06:59:24.319Z", + "end": "2023-09-13T06:59:24.400Z" + } + ] + } +} +---- + +To see the jobs instances information, if any, you can execute this query: + +[source] +---- +{ + Jobs { + id, + processId, + processInstanceId, + status, + expirationTime, + retries, + endpoint, + callbackEndpoint + } +} +---- + +The results should be something like: + +[source] +---- +{ + "data": { + "Jobs": [ + { + "id": "55c7aadb-3dff-4b97-af8e-cc45014b1c0d", + "processId": "callbackstatetimeouts", + "processInstanceId": "299886b7-2b78-4965-a701-16783c4162d8", + "status": "EXECUTED", + "expirationTime": null, + "retries": 0, + "endpoint": "http://jobs-service-postgresql/jobs", + "callbackEndpoint": "http://callbackstatetimeouts:80/management/jobs/callbackstatetimeouts/instances/299886b7-2b78-4965-a701-16783c4162d8/timers/-1" + } + ] + } +} +---- \ No newline at end of file diff --git a/serverlessworkflow/modules/ROOT/pages/data-index/data-index-usecase-multi.adoc b/serverlessworkflow/modules/ROOT/pages/data-index/data-index-usecase-multi.adoc new file mode 100644 index 0000000000..078ffe22ed --- /dev/null +++ b/serverlessworkflow/modules/ROOT/pages/data-index/data-index-usecase-multi.adoc @@ -0,0 +1,221 @@ += Deploying Data Index and multiple {product_name} application on Minikube +:compat-mode!: +// Metadata: +:description: Deploying Multiple {product_name} pushing to single Data Index on Minikube +:keywords: kogito, workflow, quarkus, serverless, kubectl, minikube, operator, dataindex +:table-caption: Data Set +// envs for common content +:kubectl_prereq: command-line tool is installed. Otherwise, Minikube handles it. +//Common constants +:data_index_ref: Data Index + + +This document describes how to deploy a multiple {product_name} workflow applications and the {data_index_ref} service using a local Kubernetes cluster, such as link:{minikube_url}[Minikube], using the link:{kogito_serverless_operator_url}[{operator_name}]. + +For more information about Minikube and related system requirements, see link:{minikube_url}/docs/start/[Getting started with Minikube] documentation. + +This use case is intended to represent an installation with: + +* A singleton Data Index Service with PostgreSQL persistence +* The `greeting` workflow (no persistence), that is configured to register events to the Data Index Service. +* The `helloworld` workflow (no persistence), that is configured to register events to the Data Index Service. +* Both workflows are configured to register the process events on the {data_index_ref} Service. + +You can directly access the UseCase2 example application we are going to follow at link:{flow_examples_operator_url}[{product_name} Use Cases repository]. + +// shared pre req +include::common/_prerequisites.adoc[] + +You can check the Minikube installation by entering the following commands in a command terminal: + +.Verify Minikube version +[source,shell] +---- +minikube version +---- + +.Verify `kubectl` CLI version +[source,shell] +---- +kubectl version +---- + +[NOTE] +==== +If `kubectl` is not installed, then Minikube handles it when you execute the following command: + +.`kubectl` is available using Minikube +[source,shell] +---- +alias kubectl="minikube kubectl --" +---- +==== + +.Procedure +. After cloning the link:{flow_examples_operator_url}[SonataFlow Use Cases repository]. Open a terminal and run the following commands +. Create the namespace: ++ +-- +[source,shell] +---- +kubectl create namespace usecase2 +---- +-- + +. Deploy the {data_index_ref} Service and postgresql database: ++ +-- + +link:{flow_examples_operator_url}/tree/main/infra/dataindex[Here] you can find the infrastructure kustomization required to deploy {data_index_ref} service and a postgresql database explained in this use case. + +.Use case kustomization.yaml resources that deploy {data_index_ref} deployment with persistence to a postgresql database +[source,yaml,subs="attributes+"] +---- +resources: +- 01-postgres.yaml <1> +- 02-dataindex.yaml <2> + +secretGenerator: + - name: postgres-secrets + literals: + - POSTGRES_USER=sonataflow + - POSTGRES_PASSWORD=sonataflow + - POSTGRES_DB=sonataflow + - PGDATA=/var/lib/postgresql/data/mydata + +configMapGenerator: + - name: dataindex-properties + files: + - application.properties +---- +<1> Postgres database deployment +<2> {data_index_ref} deployment + +Perform the deployments executing +[source,shell] +---- +kubectl kustomize infra/dataindex | kubectl apply -f - -n usecase2 +---- + +---- +configmap/dataindex-properties-hg9ff8bff5 created +secret/postgres-secrets-22tkgc2dt7 created +service/data-index-service-postgresql created +service/postgres created +persistentvolumeclaim/postgres-pvc created +deployment.apps/data-index-service-postgresql created +deployment.apps/postgres created +---- + +Give some time for the data index to start, you can check that it's running by executing. + +[source,shell] +---- +kubectl get pod -n usecase2 +---- + +---- +NAME READY STATUS RESTARTS AGE +data-index-service-postgresql-5d76dc4468-lb259 1/1 Running 0 2m11s +postgres-7f78499688-lc8n6 1/1 Running 0 2m11s +---- +-- +. Deploy the workflow: ++ +-- + +link:{flow_examples_operator_url}/tree/main/usecases/usecase2[Here] you can find the use case kustomization required to deploy the workflow + +.Use case kustomization.yaml resources that deploys the workflow +[source,yaml,subs="attributes+"] +---- +resources: +- ../../platforms/dataindex_platform +- ../../infra/service_discovery +- ../../workflows/sonataflow-greeting +- ../../workflows/sonataflow-helloworld +---- + +Perform the deployment executing +[source,shell] +---- + kubectl kustomize usecases/usecase2 | kubectl apply -f - -n usecase2 +---- + +---- +configmap/greeting-props created +configmap/helloworld-props created +sonataflow.sonataflow.org/greeting created +sonataflow.sonataflow.org/helloworld created +sonataflowplatform.sonataflow.org/sonataflow-platform created +---- + +Give some time for the sonataflow operator to build and deploy the workflow. +To check that the workflow is ready you can use this command. + +[source,shell] +---- +kubectl get workflow -n usecase2 +---- + +---- +NAME PROFILE VERSION URL READY REASON +greeting 0.0.1 True +helloworld 0.0.1 True +---- +-- + +. Expose the workflows and get the urls: ++ +-- +[source,shell] +---- +kubectl patch svc greeting helloworld -p '{"spec": {"type": "NodePort"}}' -n usecase2 +---- + +[source,shell] +---- +minikube service greeting --url -n usecase2 +---- + +[source,shell] +---- +minikube service helloworld --url -n usecase2 +---- +-- + +. Create a workflow instance: ++ +-- +You must use the URLs calculated in step 5. + +[source,shell] +---- +curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"name": "John", "language": "English"}' http://192.168.49.2:32407/greeting +---- + +[source,shell] +---- +curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{}' http://192.168.49.2:32327/helloworld +---- +-- + +. Clean the use case: ++ +-- +[source,shell] +---- +kubectl delete namespace usecase2 +---- +-- + +include::common/_querying_dataindex.adoc[] + +== Additional resources + +* xref:data-index/data-index-core-concepts.adoc[] +* xref:data-index/data-index-usecase-singleton.adoc[] +* xref:cloud/quarkus/deploying-on-minikube.adoc[] +* xref:cloud/operator/install-serverless-operator.adoc[] + +include::../../pages/_common-content/report-issue.adoc[] diff --git a/serverlessworkflow/modules/ROOT/pages/data-index/data-index-usecase-singleton.adoc b/serverlessworkflow/modules/ROOT/pages/data-index/data-index-usecase-singleton.adoc new file mode 100644 index 0000000000..1c54d8b0e2 --- /dev/null +++ b/serverlessworkflow/modules/ROOT/pages/data-index/data-index-usecase-singleton.adoc @@ -0,0 +1,206 @@ += Deploying Data Index and {product_name} application on Minikube +:compat-mode!: +// Metadata: +:description: Deploying {product_name} application and Data Index on Minikube with operator +:keywords: kogito, workflow, quarkus, serverless, kn, kubectl, minikube, operator, dataindex +:table-caption: Data Set +// envs for common content +:kubectl_prereq: command-line tool is installed. Otherwise, Minikube handles it. +//Common constants +:data_index_ref: Data Index + + +This document describes how to deploy a workflow application and the {data_index_ref} service using a local Kubernetes cluster, such as link:{minikube_url}[Minikube], using the link:{kogito_serverless_operator_url}[{operator_name}]. + +For more information about Minikube and related system requirements, see link:{minikube_url}/docs/start/[Getting started with Minikube] documentation. + +This use case is intended to represent an installation with: + +* A singleton Data Index Service with PostgreSQL persistence +* The `greeting` workflow (no persistence), that is configured to register events to the Data Index Service. + +You can directly access the UseCase1 example application we are going to follow at link:{flow_examples_operator_url}[{product_name} Use Cases repository]. + +// shared pre req +include::common/_prerequisites.adoc[] + +You can check the Minikube installation by entering the following commands in a command terminal: + +.Verify Minikube version +[source,shell] +---- +minikube version +---- + +.Verify `kubectl` CLI version +[source,shell] +---- +kubectl version +---- + +[NOTE] +==== +If `kubectl` is not installed, then Minikube handles it when you execute the following command: + +.`kubectl` is available using Minikube +[source,shell] +---- +alias kubectl="minikube kubectl --" +---- +==== + +.Procedure +. After cloning the link:{flow_examples_operator_url}[SonataFlow Use Cases repository]. Open a terminal and run the following commands +. Create the namespace: ++ +-- +[source,shell] +---- +kubectl create namespace usecase1 +---- +-- + +. Deploy the {data_index_ref} Service and postgresql database: ++ +-- +link:{flow_examples_operator_url}/tree/main/infra/dataindex[Here] you can find the infrastructure kustomization required to deploy {data_index_ref} service and a postgresql database explained in this use case. + +.Use case kustomization.yaml resources that deploy {data_index_ref} deployment with persistence to a postgresql database +[source,yaml,subs="attributes+"] +---- +resources: +- 01-postgres.yaml <1> +- 02-dataindex.yaml <2> + +secretGenerator: + - name: postgres-secrets + literals: + - POSTGRES_USER=sonataflow + - POSTGRES_PASSWORD=sonataflow + - POSTGRES_DB=sonataflow + - PGDATA=/var/lib/postgresql/data/mydata + +configMapGenerator: + - name: dataindex-properties + files: + - application.properties +---- +<1> Postgres database deployment +<2> {data_index_ref} deployment + +Perform the deployments executing +[source,shell] +---- +kubectl kustomize infra/dataindex | kubectl apply -f - -n usecase1 +---- + +---- +configmap/dataindex-properties-hg9ff8bff5 created +secret/postgres-secrets-22tkgc2dt7 created +service/data-index-service-postgresql created +service/postgres created +persistentvolumeclaim/postgres-pvc created +deployment.apps/data-index-service-postgresql created +deployment.apps/postgres created +---- + +Give some time for the data index to start, you can check that it's running by executing. + +[source,shell] +---- +kubectl get pod -n usecase1 +---- + +---- +NAME READY STATUS RESTARTS AGE +data-index-service-postgresql-5d76dc4468-lb259 1/1 Running 0 2m11s +postgres-7f78499688-lc8n6 1/1 Running 0 2m11s +---- +-- +. Deploy the workflow: ++ +-- + +link:{flow_examples_operator_url}/tree/main/usecases/usecase1[Here] you can find the use case kustomization required to deploy the workflow + +.Use case kustomization.yaml resources that deploys the workflow +[source,yaml,subs="attributes+"] +---- +resources: +- ../../platforms/dataindex_platform +- ../../infra/service_discovery +- ../../workflows/sonataflow-greeting +---- + +Perform the deployment executing + +[source,shell] +---- + kubectl kustomize usecases/usecase1 | kubectl apply -f - -n usecase1 +---- + +---- +configmap/greeting-props created +sonataflow.sonataflow.org/greeting created +sonataflowplatform.sonataflow.org/sonataflow-platform created +---- + +Give some time for the sonataflow operator to build and deploy the workflow. +To check that the workflow is ready you can use this command. + +[source,shell] +---- +kubectl get workflow -n usecase1 +---- + +---- +NAME PROFILE VERSION URL READY REASON +greeting 0.0.1 True +---- +-- + +. Expose the workflow and get the url: ++ +-- +[source,shell] +---- +kubectl patch svc greeting -p '{"spec": {"type": "NodePort"}}' -n usecase1 +---- + +[source,shell] +---- +minikube service greeting --url -n usecase1 +---- +-- + +. Create a workflow instance: ++ +-- +You must use the URLs calculated in step 5. + +[source,shell] +---- +curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"name": "John", "language": "English"}' http://192.168.49.2:32407/greeting +---- + +-- + +. Clean the use case: ++ +-- +[source,shell] +---- +kubectl delete namespace usecase1 +---- +-- + +include::common/_querying_dataindex.adoc[] + +== Additional resources + +* xref:data-index/data-index-core-concepts.adoc[] +* xref:data-index/data-index-usecase-multi.adoc[] +* xref:cloud/quarkus/deploying-on-minikube.adoc[] +* xref:cloud/operator/install-serverless-operator.adoc[] + +include::../../pages/_common-content/report-issue.adoc[] diff --git a/serverlessworkflow/modules/ROOT/pages/index.adoc b/serverlessworkflow/modules/ROOT/pages/index.adoc index 0b3470c0db..e870f7b92d 100644 --- a/serverlessworkflow/modules/ROOT/pages/index.adoc +++ b/serverlessworkflow/modules/ROOT/pages/index.adoc @@ -397,6 +397,14 @@ xref:data-index/data-index-quarkus-extension.adoc[] Explore Data Index as Quarkus extension in {PRODUCT_NAME} -- +[.card] +-- +[.card-title] +xref:data-index/data-index-usecase-singleton.adoc[Operator Data Index Deployment] +[.card-description] +Learn about the options to deploy workflow applications and Data Index using The {PRODUCT_NAME} Operator +-- + [.card-section] == Use Cases