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 4 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,69 +12,26 @@ 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 --namespace <your_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. Default location is `<project_application_dir>/manifests` directory.
You can modify these files to your liking, however when you run above command again, the changes are going to be overwritten. Use `--custom-generated-manifests-dir` or `-c` flag to generate the files in different location.

. 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 --namespace <your_namespace>
----

. List all the build configurations by running the following command:
Expand Down Expand Up @@ -113,4 +70,12 @@ Ensure that the pod corresponding to your workflow is running.
[source,terminal]
----
$ oc logs pod/<pod-name> -n workflows
----
----

.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 <your_namespace>
----
67 changes: 15 additions & 52 deletions modules/serverless-logic-deploying-workflows-dev-mode.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,69 +12,32 @@ 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
+
.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 <your_namespace>
----

. To deploy the application, apply the YAML file by entering the following command:
. 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 --namespace <your_namespace>
----
+

. Verify the deployment and check the status of the deployed workflow by entering the following command:
+
Expand Down Expand Up @@ -118,7 +81,7 @@ $ oc logs <workflow_pod_name> -n <your_namespace>
+
[source,terminal]
----
$ oc delete sonataflow <workflow_name> -n <your_namespace>
$ kn workflow undeploy -n <your_namespace>
----


Expand Down