This is an automated email from the ASF dual-hosted git repository.
wmedvedeo pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-examples.git
The following commit(s) were added to refs/heads/main by this push:
new 020b9a37f kie-kogito-examples-1892:
serverless-workflow-custom-function-knative example Quarkus3 migration
leftovers (#1893)
020b9a37f is described below
commit 020b9a37fa0307b61800da845212c543fbac4e2e
Author: Walter Medvedeo <[email protected]>
AuthorDate: Mon Mar 11 11:58:43 2024 +0100
kie-kogito-examples-1892: serverless-workflow-custom-function-knative
example Quarkus3 migration leftovers (#1893)
---
.../README.md | 68 +++++++++++++++++-----
.../custom-function-knative-service/pom.xml | 8 +--
.../src/main/resources/application.properties | 8 ++-
.../pom.xml | 1 -
.../workflow/pom.xml | 26 ++++-----
.../workflow/src/main/kubernetes/common.yml | 49 ++++++++++++++++
.../src/main/resources/application.properties | 16 ++++-
.../resources/cloudeventKnativeFunction.sw.json | 9 ++-
.../fullGvkPlainJsonKnativeFunction.sw.json | 2 +-
.../resources/plainJsonKnativeFunction.sw.json | 2 +-
10 files changed, 149 insertions(+), 40 deletions(-)
diff --git
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/README.md
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/README.md
index 4243d40c5..31c03fd5b 100644
---
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/README.md
+++
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/README.md
@@ -23,27 +23,51 @@ You will need:
- Note that GraalVM native image compilation typically requires other
packages (glibc-devel, zlib-devel and gcc) to be installed too. You also need
'native-image' installed in GraalVM (using 'gu install native-image'). Please
refer to [GraalVM installation
documentation](https://www.graalvm.org/docs/reference-manual/aot-compilation/#prerequisites)
for more details.
- minikube (https://minikube.sigs.k8s.io/docs/start/)
- Knative
[quickstarts](https://knative.dev/docs/getting-started/quickstart-install/)
- - Run `eval $(minikube -p minikube docker-env --profile knative)` to build
the images in your internal Minikube registry.
-
+
+### Minikube settings
+
+Execute this command to build the images in your Minikube internal registry.
+```shell
+eval $(minikube -p minikube docker-env --profile knative)
+```
+
+To expose the service URLs in your local environment you must start the
minikube tunnel.
+
+```shell
+# you will be asked for your admin password
+minikube tunnel --profile knative
+```
+
+### Creating the namespace
+
+```shell
+# The namespace name is very important to ensure all the services that compose
the example can interact.
+kubectl create ns custom-functions
+```
+
### Deploy the `custom-function-knative-service` project to Knative
From the `custom-function-knative-service` directory run:
```sh
-mvn clean package -Dquarkus.kubernetes.deploy=true
-Dquarkus.container-image.group=dev.local/<your_user>
+mvn clean package -Dcontainer
+```
+
+```sh
+kubectl apply -f target/kubernetes/knative.yml
```
Check if the service was successfully deployed:
```sh
-kn service list
+kn service list -n custom-functions
```
You should see something similar to (URL should change):
```sh
-NAME URL
LATEST AGE
CONDITIONS READY REASON
-custom-function-knative-service
http://custom-function-knative-service.default.10.109.169.193.sslip.io
custom-function-knative-service-00001 13s 3 OK / 3 True
+NAME URL
LATEST AGE
CONDITIONS READY REASON
+custom-function-knative-service
http://custom-function-knative-service.custom-functions.10.107.55.54.sslip.io
custom-function-knative-service-00001 53s 3 OK / 3 True
```
### Deploy the `workflow` project to Knative
@@ -51,21 +75,25 @@ custom-function-knative-service
http://custom-function-knative-service.default
From the `workflow` directory run:
```sh
-mvn clean package -Dquarkus.kubernetes.deploy=true
-Dquarkus.container-image.group=dev.local/<your_user>
+mvn clean package -Dcontainer
+```
+
+```sh
+kubectl apply -f target/kubernetes/knative.yml
```
Check if the service was successfully deployed:
```sh
-kn service list
+kn service list -n custom-functions
```
You should see both services deployed similar to (URLs should change):
```sh
-NAME URL
LATEST AGE
CONDITIONS READY REASON
-custom-function-knative-service
http://custom-function-knative-service.default.10.109.169.193.sslip.io
custom-function-knative-service-00001 3m53s 3 OK / 3 True
-workflow
http://workflow.default.10.109.169.193.sslip.io
workflow-00001 12s 3 OK / 3 True
+NAME URL
LATEST AGE
CONDITIONS READY REASON
+custom-function-knative-service
http://custom-function-knative-service.custom-functions.10.107.55.54.sslip.io
custom-function-knative-service-00001 9m45s 3 OK / 3 True
+workflow
http://workflow.custom-functions.10.107.55.54.sslip.io
workflow-00001 8s 3 OK / 3 True
```
### Submit a request with a plain JSON object
@@ -103,7 +131,10 @@ The service based on the JSON workflow definition can be
accessed by sending a r
"cloudevent": {
"specversion": "1.0",
"source": "org.acme.source",
- "type": "test"
+ "type": "test",
+ "data": {
+ "value": "test data"
+ }
}
}
```
@@ -120,11 +151,20 @@ curl -X 'POST' \
'<URL>/cloudEventKnativeFunction' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
- -d '{ "cloudevent": { "specversion": "1.0", "source": "org.acme.source",
"type": "test" }}'
+ -d '{ "cloudevent": { "specversion": "1.0", "source": "org.acme.source",
"type": "test", "data": { "value": "test data"} }}'
```
Should return something like this ("id" will change):
```json
{"id":"8dc00353-c1c6-45e9-845d-e9188d103f50","workflowdata":{"id":"response-of-org.acme.source_8dc00353-c1c6-45e9-845d-e9188d103f50","specversion":"1.0","source":"cloudEventFunction","type":"annotated"}}
-```
\ No newline at end of file
+```
+
+### Cleaning the example
+
+To remove the installed services from your minikube installation you can use
the following command:
+
+```shell
+# Note: this command might take some seconds.
+kubectl delete namespace custom-functions
+```
diff --git
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/custom-function-knative-service/pom.xml
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/custom-function-knative-service/pom.xml
index e0c14d0ec..9a39ba77b 100644
---
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/custom-function-knative-service/pom.xml
+++
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/custom-function-knative-service/pom.xml
@@ -39,9 +39,11 @@
<kogito.bom.group-id>org.kie.kogito</kogito.bom.group-id>
<kogito.bom.artifact-id>kogito-bom</kogito.bom.artifact-id>
<kogito.bom.version>999-SNAPSHOT</kogito.bom.version>
- <version.compiler.plugin>3.8.1</version.compiler.plugin>
+ <version.compiler.plugin>3.11.0</version.compiler.plugin>
<maven.compiler.release>17</maven.compiler.release>
<version.failsafe.plugin>3.0.0-M7</version.failsafe.plugin>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
@@ -79,10 +81,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes</artifactId>
</dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-container-image-jib</artifactId>
- </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-funqy-knative-events</artifactId>
diff --git
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/custom-function-knative-service/src/main/resources/application.properties
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/custom-function-knative-service/src/main/resources/application.properties
index c17fbdeed..cba1b3fe9 100644
---
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/custom-function-knative-service/src/main/resources/application.properties
+++
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/custom-function-knative-service/src/main/resources/application.properties
@@ -19,7 +19,13 @@
quarkus.native.native-image-xmx=8g
quarkus.kubernetes.deployment-target=knative
+quarkus.knative.namespace=custom-functions
+quarkus.knative.image-pull-policy=if-not-present
quarkus.funqy.knative-events.mapping.cloudEventFunction.trigger=test
quarkus.funqy.knative-events.mapping.cloudEventFunction.response-type=annotated
-quarkus.funqy.knative-events.mapping.cloudEventFunction.response-source=cloudEventFunction
\ No newline at end of file
+quarkus.funqy.knative-events.mapping.cloudEventFunction.response-source=cloudEventFunction
+
+%container.quarkus.container-image.build=true
+%container.quarkus.container-image.registry=dev.local
+%container.quarkus.container-image.group=${USER}
diff --git
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/pom.xml
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/pom.xml
index 3c99443a7..e74078993 100644
---
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/pom.xml
+++
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/pom.xml
@@ -32,7 +32,6 @@
<relativePath>../serverless-workflow-examples-parent/pom.xml</relativePath>
</parent>
- <groupId>org.kie.kogito.examples</groupId>
<artifactId>serverless-workflow-custom-function-knative</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Kogito Example :: Serverless Workflow Custom Function ::
Quarkus</name>
diff --git
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/pom.xml
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/pom.xml
index 26fd62fc3..d95295538 100644
---
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/pom.xml
+++
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/pom.xml
@@ -40,11 +40,13 @@
<kogito.bom.group-id>org.kie.kogito</kogito.bom.group-id>
<kogito.bom.artifact-id>kogito-bom</kogito.bom.artifact-id>
<kogito.bom.version>999-SNAPSHOT</kogito.bom.version>
- <version.compiler.plugin>3.8.1</version.compiler.plugin>
+ <version.compiler.plugin>3.11.0</version.compiler.plugin>
<maven.compiler.release>17</maven.compiler.release>
<version.failsafe.plugin>3.0.0-M7</version.failsafe.plugin>
<version.com.github.tomakehurst.wiremock>2.33.2</version.com.github.tomakehurst.wiremock>
<version.org.wiremock.webhooks>2.35.0</version.org.wiremock.webhooks>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
@@ -66,10 +68,6 @@
</dependencies>
</dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.kie.kogito</groupId>
- <artifactId>kogito-quarkus-serverless-workflow</artifactId>
- </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
@@ -78,9 +76,17 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-smallrye-openapi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-kubernetes</artifactId>
+ </dependency>
<dependency>
<groupId>org.kie.kogito</groupId>
- <artifactId>sonataflow-quarkus-devui</artifactId>
+ <artifactId>kogito-quarkus-serverless-workflow</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
@@ -98,14 +104,6 @@
<groupId>org.kie</groupId>
<artifactId>kogito-addons-quarkus-fabric8-kubernetes-service-catalog</artifactId>
</dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-kubernetes</artifactId>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-container-image-jib</artifactId>
- </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
diff --git
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/kubernetes/common.yml
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/kubernetes/common.yml
new file mode 100644
index 000000000..93ca6f22b
--- /dev/null
+++
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/kubernetes/common.yml
@@ -0,0 +1,49 @@
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: Role
+metadata:
+ name: service-discovery-role
+rules:
+ - apiGroups:
+ - ""
+ resources:
+ - pods
+ - services
+ verbs:
+ - get
+ - list
+ - apiGroups:
+ - apps
+ resources:
+ - deployments
+ - statefulsets
+ verbs:
+ - get
+ - list
+ - apiGroups:
+ - networking.k8s.io
+ resources:
+ - ingresses
+ verbs:
+ - get
+ - list
+ # Knative
+ - apiGroups:
+ - serving.knative.dev
+ resources:
+ - services
+ verbs:
+ - get
+ - list
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: RoleBinding
+metadata:
+ name: service-discovery-rolebinding
+roleRef:
+ apiGroup: rbac.authorization.k8s.io
+ kind: Role
+ name: service-discovery-role
+subjects:
+ - kind: ServiceAccount
+ name: default
\ No newline at end of file
diff --git
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/application.properties
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/application.properties
index ece1f7943..f37ee1ea8 100644
---
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/application.properties
+++
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/application.properties
@@ -16,6 +16,20 @@
# specific language governing permissions and limitations
# under the License.
#
+quarkus.swagger-ui.always-include=true
+kogito.devservices.enabled=false
quarkus.native.native-image-xmx=8g
-quarkus.kubernetes.deployment-target=knative
\ No newline at end of file
+quarkus.kubernetes.deployment-target=knative
+# The name of the application. This value will be used for naming Kubernetes
resources like: Deployment, Service, etc.
+quarkus.knative.name=workflow
+quarkus.knative.namespace=custom-functions
+quarkus.knative.image-pull-policy=if-not-present
+
+%container.quarkus.container-image.build=true
+# Since the Quarkus project has no java files, Quarkus 3.2.10.Final is picking
the default image
+# base: registry.access.redhat.com/ubi8/openjdk-11-runtime:1.16'. Not good,
since the workflows requires java 17.
+# Quarkus 3.8.1 picks openjdk-17 even when no java files, so this
configuration can be removed in the future.
+%container.quarkus.jib.base-jvm-image=registry.access.redhat.com/ubi8/openjdk-17-runtime:1.16
+%container.quarkus.container-image.registry=dev.local
+%container.quarkus.container-image.group=${USER}
\ No newline at end of file
diff --git
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/cloudeventKnativeFunction.sw.json
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/cloudeventKnativeFunction.sw.json
index 2b1b42026..2e7d35fc1 100644
---
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/cloudeventKnativeFunction.sw.json
+++
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/cloudeventKnativeFunction.sw.json
@@ -8,7 +8,7 @@
{
"name": "greet",
"type": "custom",
- "operation":
"knative:services.v1.serving.knative.dev/default/custom-function-knative-service?path=/cloudEventFunction&asCloudEvent=true"
+ "operation":
"knative:services.v1.serving.knative.dev/custom-functions/custom-function-knative-service?path=/cloudEventFunction&asCloudEvent=true"
}
],
"states": [
@@ -19,7 +19,12 @@
{
"functionRef": {
"refName": "greet",
- "arguments": ".cloudevent"
+ "arguments": {
+ "specversion" : ".cloudevent.specversion",
+ "type": ".cloudevent.type",
+ "source": ".cloudevent.source",
+ "data": ".cloudevent.data"
+ }
}
}
],
diff --git
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/fullGvkPlainJsonKnativeFunction.sw.json
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/fullGvkPlainJsonKnativeFunction.sw.json
index 8d76b4f1a..5eadcd992 100644
---
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/fullGvkPlainJsonKnativeFunction.sw.json
+++
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/fullGvkPlainJsonKnativeFunction.sw.json
@@ -8,7 +8,7 @@
{
"name": "greet",
"type": "custom",
- "operation":
"knative:services.v1.serving.knative.dev/custom-function-knative-service?path=/plainJsonFunction"
+ "operation":
"knative:services.v1.serving.knative.dev/custom-functions/custom-function-knative-service?path=/plainJsonFunction"
}
],
"states": [
diff --git
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/plainJsonKnativeFunction.sw.json
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/plainJsonKnativeFunction.sw.json
index 7c6912151..d29a2b248 100644
---
a/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/plainJsonKnativeFunction.sw.json
+++
b/serverless-workflow-examples/serverless-workflow-custom-function-knative/workflow/src/main/resources/plainJsonKnativeFunction.sw.json
@@ -8,7 +8,7 @@
{
"name": "greet",
"type": "custom",
- "operation":
"knative:services.v1.serving.knative.dev/default/custom-function-knative-service?path=/plainJsonFunction"
+ "operation":
"knative:services.v1.serving.knative.dev/custom-functions/custom-function-knative-service?path=/plainJsonFunction"
}
],
"states": [
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]