Skip to content

[SRVLOGIC-469]: Deploying workflows chapter does not use kn worklow plugin #85916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: serverless-docs-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 <workflow-name>.yaml -n <your_namespace>
$ kn workflow gen-manifest --profile=preview -n <namespace>
----
+
.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 `<project_application_dir>/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 <namespace>
----

. List all the build configurations by running the following command:
+
[source,terminal]
----
$ oc get buildconfigs -n workflows
$ oc get buildconfigs -n <namespace>
----

. Get the logs of the build process by running the following command:
+
[source,terminal]
----
$ oc logs buildconfig/<workflow-name> -n <your_namespace>
$ oc logs buildconfig/<workflow-name> -n <namespace>
----
+
.Example command for the `greetings-workflow.yaml` file:
.Example command for a workflow that has ID attribute with value `greeting`:
Copy link
Contributor

@adellape adellape Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No colons for titles:

Suggested change
.Example command for a workflow that has ID attribute with value `greeting`:
.Example command for a workflow that has an ID attribute with value `greeting`

[source,terminal]
----
$ oc logs buildconfig/greeting -n workflows
$ oc logs buildconfig/greeting -n <namespace>
----

.Verification
Expand All @@ -103,7 +60,7 @@ $ oc logs buildconfig/greeting -n workflows
+
[source,terminal]
----
$ oc get pods -n <your_namespace>
$ oc get pods -n <namespace>
----
+
Ensure that the pod corresponding to your workflow is running.
Expand All @@ -112,5 +69,13 @@ Ensure that the pod corresponding to your workflow is running.
+
[source,terminal]
----
$ oc logs pod/<pod-name> -n workflows
$ oc logs pod/<pod-name> -n <namespace>
----

.Cleanup
Copy link
Contributor

@adellape adellape Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically .Cleanup is a non-standard heading for a procedure module (per modular docs guide). FWIW, I see only 1 other instance in the repo (though, that one has it as .Clean up two-words; the single-word here is correctly what IBM Style Guide suggests).

Could this instead just be the last step in the normal .Procedure? Or maybe the last step in .Verification? Alternatively, could be split out into its own procedure module "Cleaning up a workflow deployment" but that seems like overkill.

. To cleanup the deployment, delete the projects resources running the following command:
Copy link
Contributor

@adellape adellape Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way though, if this stays as a single-step procedure, use an unordered list (per guidelines) and use "by running":

Suggested change
. To cleanup the deployment, delete the projects resources running the following command:
* To cleanup the deployment, delete the projects resources by running the following command:

+
[source,terminal]
----
$ kn workflow undeploy -n <namespace>
----
101 changes: 45 additions & 56 deletions modules/serverless-logic-deploying-workflows-dev-mode.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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=<your_token> --server=<your_clusters_server_url>
----

. 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 <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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
. Deploy the application, by running the following command:
. Deploy the application by running the following command:

+
[source,terminal]
----
$ oc apply -f <filename> -n <your_namespace>
$ kn workflow deploy -n <namespace>
----

. Verify the deployment and check the status of the deployed workflow by entering the following command:
+
[source,terminal]
----
$ oc get workflow -n <your_namespace> -w
$ oc get workflow -n <namespace>
----
+
Ensure that your workflow is listed and the status is `Running` or `Completed`.
Expand All @@ -89,7 +53,7 @@ Ensure that your workflow is listed and the status is `Running` or `Completed`.
+
[source,terminal]
----
$ oc edit sonataflow <workflow_name> -n <your_namespace>
$ oc edit sonataflow <workflow_name> -n <namespace>
----

. After editing, save the changes. The {ServerlessLogicOperatorName} detects the changes and updates the workflow accordingly.
Expand All @@ -102,23 +66,48 @@ $ oc edit sonataflow <workflow_name> -n <your_namespace>
+
[source,terminal]
----
$ oc get sonataflows -n <your_namespace>
$ oc get sonataflows -n <namespace>
----

.. Find the pod of your application by running the following command:
+
[source,terminal]
----
$ oc get pods -n <namespace>
----

.. View the workflow logs by running the following command:
+
[source,terminal]
----
$ oc logs <workflow_pod_name> -n <your_namespace>
$ oc logs <workflow_pod_name> -n <namespace>
----

.Testing
Copy link
Contributor

@adellape adellape Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thought re: non-standard heading for this .Testing one. This one, however, feels like splitting it out as its own procedure would be worthwhile (versus including it within some other procedure module).

Edit: I see now there already is a "Testing a deployment" procedure later in the assembly. Is that basically the same procedure that's being shown here? If so, could there just be an "Additional resources" link to that procedure from this one instead of duplicating?


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/<workflow_name> -n <namespace>
----
+
Note the value of `HOST/PORT` from the result of tis command, referenced as `<WORKFLOW_URL>` in next step.
Copy link
Contributor

@adellape adellape Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo x2:

Suggested change
Note the value of `HOST/PORT` from the result of tis command, referenced as `<WORKFLOW_URL>` in next step.
Note the value of `HOST/PORT` from the result of this command, referenced as `<WORKFLOW_URL>` in the next step.

Also, if <WORKFLOW_URL> only appears as part of this documentation / procedure, could it be all-owercase like a normal user-replaceable per guidelines? E.g.:

Suggested change
Note the value of `HOST/PORT` from the result of tis command, referenced as `<WORKFLOW_URL>` in next step.
Note the value of `HOST/PORT` from the result of this command, referenced as `<workflow_url>` in the next step.

If it has meaning as all-cap outside of this procedure, however (like in output or the UI someplace), then ignore.


.. Navigate to the `<WORKFLOW_URL>/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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re: previous comment, match lowercase here as well, if you change the other:

Suggested change
.. Navigate to the `<WORKFLOW_URL>/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.
.. Navigate to the `<workflow_url>/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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Don't need "please", or maybe even "note".
  • "might" instead of "may" (better for translation).
Suggested change
.. Navigate to the `<WORKFLOW_URL>/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.
.. Navigate to the `<WORKFLOW_URL>/q/dev-ui/org.apache.kie.sonataflow.sonataflow-quarkus-devui/workflows` in your browser. It might take some time until the management console is available.



.Next steps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This single-step .Next steps procedure could probably just be absorbed into wherever the .Testing procedure above it ends up.


. After completing the testing, delete the resources to avoid unnecessary usage by running the following command:
+
[source,terminal]
----
$ oc delete sonataflow <workflow_name> -n <your_namespace>
$ kn workflow undeploy -n <namespace>
----


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop "the":

Suggested change
* You have deployed your workflow in preview mode in the {ocp-product-title}.
* You have deployed your workflow in preview mode in {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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be plural?

Suggested change
. Retrieve the list of service and identify the one matching `name` of your workflow:
. Retrieve the list of services and identify the one matching the `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 <namespace>
----

. Create a route for the workflow service by running the following command:
+
[source,terminal]
----
$ oc expose svc/<workflow-service-name> -n workflows
$ oc expose svc/<workflow-service-name> -n <namespace>
----
+
This command creates a public URL to access the workflow service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand Down