diff --git a/modules/serverless-logic-building-deploying-workflow-preview-mode.adoc b/modules/serverless-logic-building-deploying-workflow-preview-mode.adoc index 8748e46ff54d..d2052d2e0a6e 100644 --- a/modules/serverless-logic-building-deploying-workflow-preview-mode.adoc +++ b/modules/serverless-logic-building-deploying-workflow-preview-mode.adoc @@ -12,89 +12,46 @@ You can create a `SonataFlow` custom resource (CR) on {ocp-product-title} and {S * You have an {ServerlessLogicOperatorName} installed on your cluster. * You have access to an {ServerlessLogicProductName} project with the appropriate roles and permissions to create applications and other workloads in {ocp-product-title}. +* You have installed the {ServerlessLogicProductName} `kn-workflow` CLI plugin. * You have installed the OpenShift CLI `(oc)`. .Procedure -. Create a workflow YAML file similar to the following: -+ -[source,yaml] ----- -apiVersion: sonataflow.org/v1alpha08 -kind: SonataFlow -metadata: - name: greeting - annotations: - sonataflow.org/description: Greeting example on k8s! - sonataflow.org/version: 0.0.1 -spec: - flow: - start: ChooseOnLanguage - functions: - - name: greetFunction - type: custom - operation: sysout - states: - - name: ChooseOnLanguage - type: switch - dataConditions: - - condition: "${ .language == \"English\" }" - transition: GreetInEnglish - - condition: "${ .language == \"Spanish\" }" - transition: GreetInSpanish - defaultCondition: GreetInEnglish - - name: GreetInEnglish - type: inject - data: - greeting: "Hello from JSON Workflow, " - transition: GreetPerson - - name: GreetInSpanish - type: inject - data: - greeting: "Saludos desde JSON Workflow, " - transition: GreetPerson - - name: GreetPerson - type: operation - actions: - - name: greetAction - functionRef: - refName: greetFunction - arguments: - message: ".greeting+.name" - end: true ----- - -. Apply the `SonataFlow` workflow definition to your {ocp-product-title} namespace by running the following command: +. In your project application directory, execute the following command: + [source,terminal] ---- -$ oc apply -f .yaml -n +$ kn workflow gen-manifest --profile=preview -n ---- + -.Example command for the `greetings-workflow.yaml` file: +This command generates {ocp-product-title} YAML manifests based on your `workflow.sw.json|yaml` definition. The default location is the `/manifests` directory. +You can modify these files to your preference, however, when you rerun the above command, the changes will be overwritten. Use the `--custom-generated-manifests-dir` or `-c` flag to generate the files in different locations. + +. Deploy the `SonataFlow` workflow application to your {ocp-product-title} namespace by running the following command: ++ [source,terminal] ---- -$ oc apply -f greetings-workflow.yaml -n workflows +$ kn workflow deploy --custom-manifests-dir=./manifests -n ---- . List all the build configurations by running the following command: + [source,terminal] ---- -$ oc get buildconfigs -n workflows +$ oc get buildconfigs -n ---- . Get the logs of the build process by running the following command: + [source,terminal] ---- -$ oc logs buildconfig/ -n +$ oc logs buildconfig/ -n ---- + -.Example command for the `greetings-workflow.yaml` file: +.Example command for a workflow that has ID attribute with value `greeting`: [source,terminal] ---- -$ oc logs buildconfig/greeting -n workflows +$ oc logs buildconfig/greeting -n ---- .Verification @@ -103,7 +60,7 @@ $ oc logs buildconfig/greeting -n workflows + [source,terminal] ---- -$ oc get pods -n +$ oc get pods -n ---- + Ensure that the pod corresponding to your workflow is running. @@ -112,5 +69,13 @@ Ensure that the pod corresponding to your workflow is running. + [source,terminal] ---- -$ oc logs pod/ -n workflows +$ oc logs pod/ -n +---- + +.Cleanup +. To cleanup the deployment, delete the projects resources running the following command: ++ +[source,terminal] +---- +$ kn workflow undeploy -n ---- \ No newline at end of file diff --git a/modules/serverless-logic-deploying-workflows-dev-mode.adoc b/modules/serverless-logic-deploying-workflows-dev-mode.adoc index 9a64dac27aa5..0944d3992bb2 100644 --- a/modules/serverless-logic-deploying-workflows-dev-mode.adoc +++ b/modules/serverless-logic-deploying-workflows-dev-mode.adoc @@ -12,75 +12,39 @@ You can deploy your local workflow on {ocp-product-title} in Dev mode. You can u * You have {ServerlessLogicOperatorName} installed on your cluster. * You have access to a {ServerlessLogicProductName} project with the appropriate roles and permissions to create applications and other workloads in {ocp-product-title}. +* You have installed the {ServerlessLogicProductName} `kn-workflow` CLI plugin. * You have installed the OpenShift CLI `(oc)`. .Procedure -. Create the workflow configuration YAML file. +. Login to your cluster, by running the following command: + -.Example `workflow-dev.yaml` file -[source,yaml] ----- -apiVersion: sonataflow.org/v1alpha08 -kind: SonataFlow -metadata: - name: greeting <1> - annotations: - sonataflow.org/description: Greeting example on k8s! - sonataflow.org/version: 0.0.1 - sonataflow.org/profile: dev <2> -spec: - flow: - start: ChooseOnLanguage - functions: - - name: greetFunction - type: custom - operation: sysout - states: - - name: ChooseOnLanguage - type: switch - dataConditions: - - condition: "${ .language == \"English\" }" - transition: GreetInEnglish - - condition: "${ .language == \"Spanish\" }" - transition: GreetInSpanish - defaultCondition: GreetInEnglish - - name: GreetInEnglish - type: inject - data: - greeting: "Hello from JSON Workflow, " - transition: GreetPerson - - name: GreetInSpanish - type: inject - data: - greeting: "Saludos desde JSON Workflow, " - transition: GreetPerson - - name: GreetPerson - type: operation - actions: - - name: greetAction - functionRef: - refName: greetFunction - arguments: - message: ".greeting + .name" - end: true +[source,terminal] +---- +$ oc login --token= --server= ---- + +. Create a namespace in your cluster, by running the following command: + -<1> is a workflow_name -<2> indicates that you must deploy the workflow in Dev mode +[source,terminal] +---- +$ oc create namespace +---- -. To deploy the application, apply the YAML file by entering the following command: +. In your terminal, navigate to the root directory of your {ServerlessLogicProductName} project. + +. Deploy the application, by running the following command: + [source,terminal] ---- -$ oc apply -f -n +$ kn workflow deploy -n ---- . Verify the deployment and check the status of the deployed workflow by entering the following command: + [source,terminal] ---- -$ oc get workflow -n -w +$ oc get workflow -n ---- + Ensure that your workflow is listed and the status is `Running` or `Completed`. @@ -89,7 +53,7 @@ Ensure that your workflow is listed and the status is `Running` or `Completed`. + [source,terminal] ---- -$ oc edit sonataflow -n +$ oc edit sonataflow -n ---- . After editing, save the changes. The {ServerlessLogicOperatorName} detects the changes and updates the workflow accordingly. @@ -102,23 +66,48 @@ $ oc edit sonataflow -n + [source,terminal] ---- -$ oc get sonataflows -n +$ oc get sonataflows -n +---- + +.. Find the pod of your application by running the following command: ++ +[source,terminal] +---- +$ oc get pods -n ---- .. View the workflow logs by running the following command: + [source,terminal] ---- -$ oc logs -n +$ oc logs -n ---- +.Testing + +The {ServerlessLogicOperatorName} automatically generates a route for workflow deployments using the `dev` profile. To test your workflow, you can use management console that is accessible via the created route. The management console allows you execute the workflow and inspect executed the instances in detail. + +. Access the management console by excuting following steps: + +.. Retrieve the public URL to access the workflow service by running the following command: ++ +[source,terminal] +---- +$ oc get route/ -n +---- ++ +Note the value of `HOST/PORT` from the result of tis command, referenced as `` in next step. + +.. Navigate to the `/q/dev-ui/org.apache.kie.sonataflow.sonataflow-quarkus-devui/workflows` in your browser. Please note that it may take some time until the management console is available. + + .Next steps . After completing the testing, delete the resources to avoid unnecessary usage by running the following command: + [source,terminal] ---- -$ oc delete sonataflow -n +$ kn workflow undeploy -n ---- diff --git a/modules/serverless-logic-verifying-workflow-deployment-preview-mode.adoc b/modules/serverless-logic-verifying-workflow-deployment-preview-mode.adoc index fa5ab63da538..2be8b49b163d 100644 --- a/modules/serverless-logic-verifying-workflow-deployment-preview-mode.adoc +++ b/modules/serverless-logic-verifying-workflow-deployment-preview-mode.adoc @@ -13,62 +13,22 @@ You can verify that your {ServerlessLogicProductName} workflow is running by per * You have an {ServerlessLogicOperatorName} installed on your cluster. * You have access to an {ServerlessLogicProductName} project with the appropriate roles and permissions to create applications and other workloads in {ocp-product-title}. * You have installed the OpenShift CLI `(oc)`. +* You have deployed your workflow in preview mode in the {ocp-product-title}. .Procedure -. Create a workflow `YAML` file similar to the following: +. Retrieve the list of service and identify the one matching `name` of your workflow: + -[source,yaml] +[source,terminal] ---- -apiVersion: sonataflow.org/v1alpha08 -kind: SonataFlow -metadata: - name: greeting - annotations: - sonataflow.org/description: Greeting example on k8s! - sonataflow.org/version: 0.0.1 -spec: - flow: - start: ChooseOnLanguage - functions: - - name: greetFunction - type: custom - operation: sysout - states: - - name: ChooseOnLanguage - type: switch - dataConditions: - - condition: "${ .language == \"English\" }" - transition: GreetInEnglish - - condition: "${ .language == \"Spanish\" }" - transition: GreetInSpanish - defaultCondition: GreetInEnglish - - name: GreetInEnglish - type: inject - data: - greeting: "Hello from JSON Workflow, " - transition: GreetPerson - - name: GreetInSpanish - type: inject - data: - greeting: "Saludos desde JSON Workflow, " - transition: GreetPerson - - name: GreetPerson - type: operation - actions: - - name: greetAction - functionRef: - refName: greetFunction - arguments: - message: ".greeting+.name" - end: true +$ oc get svc -n ---- . Create a route for the workflow service by running the following command: + [source,terminal] ---- -$ oc expose svc/ -n workflows +$ oc expose svc/ -n ---- + This command creates a public URL to access the workflow service. diff --git a/serverless-logic/serverless-logic-getting-started/serverless-logic-deploying-workflows.adoc b/serverless-logic/serverless-logic-getting-started/serverless-logic-deploying-workflows.adoc index 05171b0193ac..e85bd97cb5d7 100644 --- a/serverless-logic/serverless-logic-getting-started/serverless-logic-deploying-workflows.adoc +++ b/serverless-logic/serverless-logic-getting-started/serverless-logic-deploying-workflows.adoc @@ -25,6 +25,10 @@ To deploy a workflow in Preview mode, {ServerlessLogicOperatorName} uses the bui The following sections explain how to build and deploy your workflow on a cluster using the {ServerlessLogicOperatorName} with a `SonataFlow` custom resource. +include::modules/serverless-logic-building-deploying-workflow-preview-mode.adoc[leveloffset=+2] +include::modules/serverless-logic-verifying-workflow-deployment-preview-mode.adoc[leveloffset=+2] +include::modules/serverless-logic-restarting-the-build-preview-mode.adoc[leveloffset=+2] + [id="serverless-logic-configuring-workflows-preview-mode_{context}"] === Configuring workflows in Preview mode @@ -34,9 +38,6 @@ include::modules/serverless-logic-workflow-changing-resource-requirements.adoc[l include::modules/serverless-logic-workflow-passing-arguments-internal-builder.adoc[leveloffset=+3] include::modules/serverless-logic-workflow-env-variables-internal-builder.adoc[leveloffset=+3] include::modules/serverless-logic-workflow-changing-base-builder-image.adoc[leveloffset=+3] -include::modules/serverless-logic-building-deploying-workflow-preview-mode.adoc[leveloffset=+2] -include::modules/serverless-logic-verifying-workflow-deployment-preview-mode.adoc[leveloffset=+2] -include::modules/serverless-logic-restarting-the-build-preview-mode.adoc[leveloffset=+2] include::modules/serverless-logic-editing-workflows.adoc[leveloffset=+1] include::modules/serverless-logic-testing-workflows.adoc[leveloffset=+1]