Skip to content

Commit

Permalink
[NU-1069] streaming-lite and request-response modes replaced by one l…
Browse files Browse the repository at this point in the history
…ite-k8s (#137)
  • Loading branch information
arkadius authored Mar 4, 2024
1 parent b6b1f4d commit 5dfd18a
Show file tree
Hide file tree
Showing 16 changed files with 174 additions and 99 deletions.
21 changes: 21 additions & 0 deletions deploy-values-lite-both-processing-modes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
image:
tag: staging-latest
pullPolicy: Always

flink:
enabled: false

nussknacker:
mode: "lite-k8s"

telegraf:
enabled: false

zookeeper:
enabled: false

kafka:
kraft:
enabled: true
externalZookeeper:
servers: []
4 changes: 3 additions & 1 deletion deploy-values-request-response.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ image:
pullPolicy: Always

nussknacker:
mode: "request-response"
mode: "lite-k8s"
streaming:
enabled: false

flink:
enabled: false
Expand Down
4 changes: 3 additions & 1 deletion deploy-values-streaming-lite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ flink:
enabled: false

nussknacker:
mode: "streaming-lite"
mode: "lite-k8s"
requestResponse:
enabled: false

telegraf:
enabled: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#This configuration shows how to use custom images for streaming-lite mode (for Flink mode you only have to configure image.repository)
#This configuration shows how to use custom images for lite-k8s mode (for Flink mode you only have to configure image.repository)
#This assumes that nussknacker-sample-components and nussknacker-sample-components-lite-runtime-app images
#(created e.g. with https://github.com/TouK/nussknacker-sample-components)
#are available in K8s cluster. If k3d is used, the image has to imported first.
Expand Down
19 changes: 10 additions & 9 deletions examples/customComponents/custom-component-url-values.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#This configuration shows how to use custom components/libs by custom URL for streaming-lite mode (for Flink mode you only have to configure nussknacker.modelClasspath)
#This configuration shows how to use custom components/libs by custom URL for lite-k8s mode (for Flink mode you only have to configure nussknacker.streaming.modelClassPath)
#This assumes that URL points to location accessible from container, which contains jar with all needed dependencies
#Here we add custom DB driver, as it's easy to use
nussknacker:
#At the moment one has to override whole classPath to add custom entries
modelClassPath: &modelClassPath
- "model/defaultModel.jar"
- "components/lite/liteBase.jar"
- "components/lite/liteKafka.jar"
- "components/common"
- "https://repo1.maven.org/maven2/org/hsqldb/hsqldb/2.6.1/hsqldb-2.6.1.jar"
streaming:
modelClassPath: &streamingModelClassPath
- "model/defaultModel.jar"
- "components/lite/liteBase.jar"
- "components/lite/liteKafka.jar"
- "components/common"
- "https://repo1.maven.org/maven2/org/hsqldb/hsqldb/2.6.1/hsqldb-2.6.1.jar"

modelConfig:
components:
Expand All @@ -25,5 +26,5 @@ nussknacker:
scenarioTypes:
default:
deploymentConfig:
configExecutionOverrides:
modelClassPath: *modelClassPath
configExecutionOverrides:
modelClassPath: *streamingModelClassPath
2 changes: 1 addition & 1 deletion examples/customConfig/custom-conf-values.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#This configuration shows how to run NU designer using configuration from external file provided from configmap
nussknacker:
mode: "streaming-lite"
mode: "lite-k8s"
configFile: /etc/nussknacker/application.conf,/etc/nussknacker/extra/extra-application.conf

additionalVolumes:
Expand Down
2 changes: 1 addition & 1 deletion examples/customSecret/custom-secret-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extraEnv:
name: 'nussknacker-secrets'
key: OPEN_API_KEY
nussknacker:
mode: "streaming-lite"
mode: "lite-k8s"
k8sDeploymentConfig:
spec:
template:
Expand Down
42 changes: 23 additions & 19 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,32 @@ Modes

The `mode` configuration variable is a convenient umbrella term for the processing mode and engine. See [Glossary](https://nussknacker.io/documentation/about/GLOSSARY) for the explanation of these terms.

By default, the chart runs Nussknacker in `flink` mode which deploys scenarios to Flink engine (either installed directly by the chart, or external one). It is also possible to run Nussknacker on K8s in `streaming-lite` and `request-response` modes. You will need to manually adjust values of the following variables if you use `mode` other than `flink`.

For:
* `streaming-lite` mode:
By default, the chart runs Nussknacker in `flink` mode which deploys scenarios to Flink engine (either installed directly by the chart, or external one). It is also possible to run Nussknacker on K8s in `lite-k8s` mode. You will need to manually adjust values of the following variables if you use this `mode`:
```
nussknacker:
mode: streaming-lite
mode: lite-k8s
flink:
enable: false
telegraf:
enabled: false
```
* `request-response` mode

In case if you want to use only request-response processing mode in your scenarios you can also disable streaming part of the application stack:
```
nussknacker:
mode: request-response
mode: lite-k8s
streaming:
enabled: false
flink:
enable: false
telegraf:
enabled: false
kafka:
enabled: false
zookeeper:
enabled: false
apicurio-registry:
enabled: false
```

Configuration
Expand Down Expand Up @@ -120,8 +123,8 @@ Nussknacker configuration consists of three [configuration areas](https://nusskn
included in ```modelConfig``` section of the configuration
- `uiConfig` - modifies the Designer configuration options. You can override things like environment name, metrics and so on. They are included on the root level of ```application.conf```
- the Deployment Manager configuration parameters (and Helm variables) are documented fully in Nussknacker configuration [documentation](https://nussknacker.io/documentation/docs/next/installation_configuration_guide/DeploymentManagerConfiguration#lite-engine-based-on-kubernetes); below we mention just those which are most often modified:
- `k8sDeploymentConfig` - here you can specify your own k8s runtime deployment yaml config in `streaming-lite` and `request-response` modes
- `requestResponse` - here you can specify `servicePort` and `ingress` configuration for deployed scenarios on k8s when running in `request-response` mode
- `k8sDeploymentConfig` - here you can specify your own k8s runtime deployment yaml config in `lite-k8s` mode
- `requestResponse` - here you can specify `servicePort` and `ingress` configuration for deployed scenarios on k8s when running in `lite-k8s` mode

Yaml keys expected by Nussknacker to be in the form of nested yaml structures in the Values file are converted to json; check the chart implementation if in doubt.

Expand Down Expand Up @@ -165,20 +168,21 @@ configuration adding additional JDBC driver for [SQL enrichers](https://docs.nus
```
nussknacker:
#At the moment one has to override whole classPath to add custom entries
modelClassPath: &modelClassPath
- "model/defaultModel.jar"
- "components/lite/liteBase.jar"
- "components/lite/liteKafka.jar"
- "components/common"
- "https://repo1.maven.org/maven2/org/hsqldb/hsqldb/2.6.1/hsqldb-2.6.1.jar"
streaming:
modelClassPath: &streamingModelClassPath
- "model/defaultModel.jar"
- "components/lite/liteBase.jar"
- "components/lite/liteKafka.jar"
- "components/common"
- "https://repo1.maven.org/maven2/org/hsqldb/hsqldb/2.6.1/hsqldb-2.6.1.jar"
uiConfig:
scenarioTypes:
default:
deploymentConfig:
configExecutionOverrides:
modelClassPath: *modelClassPath
modelClassPath: *streamingModelClassPath
```
Again, for `flink` mode it's only necessary to set `modelClassPath`.
Again, for `flink` mode it's only necessary to set `streamingModelClassPath`.

Security/RBAC
-------------
Expand Down Expand Up @@ -277,7 +281,7 @@ You can deploy configMap/secret on your own using, or use special `extraDeploy`
Example:
```
nussknacker:
mode: "streaming-lite"
mode: "lite-k8s"
configFile: /etc/nussknacker/application.conf,/etc/nussknacker/extra/extra-application.conf
additionalVolumes:
Expand Down
5 changes: 3 additions & 2 deletions src/bats-suites/kafka-only.bats
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
: "${AUTHORIZATION:?required environment value not set}"
: "${KAFKA_BOOTSTRAP_SERVER:?required environment value not set}"
: "${SCHEMA_REGISTRY_URL:?required environment value not set}"
: "${SCENARIO_TYPE:?required environment value not set}"
: "${STREAMING_SCENARIO_TYPE:?required environment value not set}"

function curl() {
/usr/bin/curl -f -k -v -H "Content-type: application/json" -H "Authorization: ${AUTHORIZATION}" "$@"
Expand Down Expand Up @@ -38,12 +38,13 @@ _END
function given_a_proxy_process() {
local PROCESS_NAME="${1:?required}"
local PROCESS_OBJECT="${2:?required}"
local PROCESSES_URL="${NUSSKNACKER_URL%/}/api/processes"
local PROCESS_URL=$(echo ${NUSSKNACKER_URL%/}/api/processes/${PROCESS_NAME} | sed -e 's/ /%20/g')
local PROCESS_DEPLOY_URL=$(echo ${NUSSKNACKER_URL%/}/api/processManagement/deploy/${PROCESS_NAME} | sed -e 's/ /%20/g')
local PROCESS_CANCEL_URL=$(echo ${NUSSKNACKER_URL%/}/api/processManagement/cancel/${PROCESS_NAME} | sed -e 's/ /%20/g')
local PROCESS_IMPORT_URL=$(echo ${NUSSKNACKER_URL%/}/api/processes/import/${PROCESS_NAME} | sed -e 's/ /%20/g')

curl ${PROCESS_URL} || curl -X POST ${PROCESS_URL%/}/Default
curl ${PROCESS_URL} || echo "{ \"name\": \"$PROCESS_NAME\", \"processingMode\": \"Unbounded-Stream\", \"isFragment\": false }" | curl -X POST ${PROCESSES_URL} -d @-
echo ${PROCESS_OBJECT} | /usr/bin/curl -f -k -v -H "Authorization: ${AUTHORIZATION}" ${PROCESS_IMPORT_URL} -F process=@- | jq .scenarioGraph | (echo '{ "comment": "created by a bats test", "scenarioGraph": '; cat; echo '}') | curl -X PUT ${PROCESS_URL} -d @-

[[ $(curl ${PROCESS_URL%/}/status | jq -r .status.name) == "RUNNING" ]] && curl -X POST ${PROCESS_CANCEL_URL}
Expand Down
6 changes: 3 additions & 3 deletions src/bats-suites/rr-only.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

: "${NUSSKNACKER_URL:?required environment value not set}"
: "${AUTHORIZATION:?required environment value not set}"
: "${SCENARIO_TYPE:?required environment value not set}"

function curl() {
/usr/bin/curl -f -k -v -H "Content-type: application/json" -H "Authorization: ${AUTHORIZATION}" "$@"
Expand Down Expand Up @@ -31,11 +30,12 @@ function wait_for_status() {

function given_a_proxy_process() {
local PROCESS_NAME="${1:?required}"
local PROCESSES_URL="${NUSSKNACKER_URL%/}/api/processes"
local PROCESS_URL=$(echo ${NUSSKNACKER_URL%/}/api/processes/${PROCESS_NAME} | sed -e 's/ /%20/g')
local PROCESS_DEPLOY_URL=$(echo ${NUSSKNACKER_URL%/}/api/processManagement/deploy/${PROCESS_NAME} | sed -e 's/ /%20/g')
local PROCESS_IMPORT_URL=$( echo ${NUSSKNACKER_URL%/}/api/processes/import/${PROCESS_NAME} | sed -e 's/ /%20/g')

curl ${PROCESS_URL} || curl -X POST ${PROCESS_URL%/}/Default
curl ${PROCESS_URL} || echo "{ \"name\": \"$PROCESS_NAME\", \"processingMode\": \"Request-Response\", \"isFragment\": false }" | curl -X POST ${PROCESSES_URL} -d @-
export PROCESS_NAME GROUP INPUT_TOPIC OUTPUT_TOPIC
cat ${BATS_TEST_DIRNAME}/rr-testprocess.json | envsubst | /usr/bin/curl -f -k -v -H "Authorization: ${AUTHORIZATION}" ${PROCESS_IMPORT_URL} -F process=@- | jq .scenarioGraph | (echo '{ "comment": "created by a bats test", "scenarioGraph": '; cat; echo '}') | curl -X PUT ${PROCESS_URL} -d @-

Expand All @@ -58,7 +58,7 @@ function setup() {
INPUT_MESSAGE='{"productId":10}'
EXPECTED_OUTPUT_MESSAGE='{"productId":20}'

if [[ $(curl $SCENARIO_URL -d $INPUT_MESSAGE) == $EXPECTED_OUTPUT_MESSAGE ]]; then echo ok; else exit 1; fi
if [[ $(curl $RR_SCENARIO_INPUT_URL -d $INPUT_MESSAGE) == $EXPECTED_OUTPUT_MESSAGE ]]; then echo ok; else exit 1; fi

cancel_process "$PROCESS_NAME"
wait_for_status "$PROCESS_NAME" "CANCELED"
Expand Down
11 changes: 3 additions & 8 deletions src/bats-suites/rr-testprocess.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
{
"metaData" : {
"id" : "test-scenario-for-rr-only",
"typeSpecificData" : {
"slug" : "test-scenario-for-rr-only",
"type" : "RequestResponseMetaData"
},
"additionalFields" : {
"description" : null,
"properties" : {
"slug" : "test-scenario-for-rr-only",
"inputSchema" : "{\n \"title\": \"Product\",\n \"description\": \"A product from Acme's catalog\",\n \"type\": \"object\",\n \"properties\": {\n \"productId\": {\n \"description\": \"The unique identifier for a product\",\n \"type\": \"integer\"\n }\n },\n \"required\": [ \"productId\" ]\n}",
"outputSchema" : "{\n \"title\": \"Product\",\n \"description\": \"A product from Acme's catalog\",\n \"type\": \"object\",\n \"properties\": {\n \"productId\": {\n \"description\": \"The unique identifier for a product\",\n \"type\": \"integer\"\n }\n },\n \"required\": [ \"productId\" ]\n}"
}
},
"subprocessVersions" : {

},
"metaDataType": "RequestResponseMetaData"
}
},
"nodes" : [
Expand Down
17 changes: 3 additions & 14 deletions src/bats-suites/testprocess.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
{
"metaData": {
"id": "${PROCESS_NAME}",
"typeSpecificData": {
"parallelism": 1,
"type": "${SCENARIO_TYPE}"
},
"isSubprocess": false,
"additionalFields": {
"description": null,
"groups": [
],
"properties": {
}
},
"subprocessVersions": {
"parallelism": "1"
},
"metaDataType": "${STREAMING_SCENARIO_TYPE}"
}
},
"exceptionHandlerRef": {
"parameters": [
]
},
"nodes": [
{
"id": "kafka-source",
Expand Down
37 changes: 21 additions & 16 deletions src/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -169,34 +169,41 @@ http://{{ include "apicurio-registry.fullname" ( index .Subcharts "apicurio-regi
http://{{ include "influxdb.fullname" (dict "Chart" (dict "Name" "influxdb") "Values" .Values.influxdb "Release" .Release "Capabilities" .Capabilities) }}:8086
{{- end -}}

{{- define "nussknacker.defaultDashboard" -}}
{{- define "nussknacker.streaming.dashboard" -}}
{{- if eq .Values.nussknacker.mode "flink" -}}
nussknacker-scenario
{{- else if eq .Values.nussknacker.mode "streaming-lite" -}}
{{- else if eq .Values.nussknacker.mode "lite-k8s" -}}
nussknacker-lite-scenario
{{- else if eq .Values.nussknacker.mode "request-response" -}}
nussknacker-request-response-scenario
{{- else -}}
{{- .Values.nussknacker.defaultDashboard }}
{{- .Values.nussknacker.streaming.dashboard }}
{{- end -}}
{{- end -}}

{{- define "nussknacker.modelClassPath" -}}
{{- if .Values.nussknacker.modelClassPath -}}
{{ tpl ( mustToJson .Values.nussknacker.modelClassPath) . }}
{{- define "nussknacker.streaming.modelClassPath" -}}
{{- if .Values.nussknacker.streaming.modelClassPath -}}
{{ tpl ( mustToJson .Values.nussknacker.streaming.modelClassPath) . }}
{{- else if eq .Values.nussknacker.mode "flink" -}}
["model/defaultModel.jar", "model/flinkExecutor.jar", "components/flink", "components/common"]
{{- else if eq .Values.nussknacker.mode "ververica" -}}
["model/defaultModel.jar", "model/flinkExecutor.jar", "components/flink", "components/common", "compatibility-provider/nussknacker-ververica-compatibility-provider.jar"]
{{- else if eq .Values.nussknacker.mode "streaming-lite" -}}
{{- else if eq .Values.nussknacker.mode "lite-k8s" -}}
["model/defaultModel.jar", "components/lite/liteBase.jar", "components/lite/liteKafka.jar", "components/common"]
{{- else if eq .Values.nussknacker.mode "request-response" -}}
["model/defaultModel.jar", "components/lite/liteBase.jar", "components/lite/liteRequestResponse.jar", "components/common"]
{{- else -}}
{{- fail "Value for .Values.nussknacker.mode is not supported. Supported modes are: flink, streaming-lite and request-response" }}
{{- fail "Value for .Values.nussknacker.mode is not supported. Supported modes are: flink, ververica and lite-k8s" }}
{{- end -}}
{{- end -}}

{{- define "nussknacker.requestResponse.modelClassPath" -}}
{{- if .Values.nussknacker.requestResponse.modelClassPath -}}
{{ tpl ( mustToJson .Values.nussknacker.requestResponse.modelClassPath) . }}
{{- else if or (eq .Values.nussknacker.mode "flink") (eq .Values.nussknacker.mode "ververica") -}}
[]
{{- else if eq .Values.nussknacker.mode "lite-k8s" -}}
["model/defaultModel.jar", "components/lite/liteBase.jar", "components/lite/liteRequestResponse.jar", "components/common"]
{{- else -}}
{{- fail "Value for .Values.nussknacker.mode is not supported. Supported modes are: flink, ververica and lite-k8s" }}
{{- end -}}
{{- end -}}

{{- define "nussknacker.influxDbConfig" -}}
{
Expand All @@ -211,13 +218,11 @@ nussknacker-request-response-scenario
}
{{- end -}}

{{- define "nussknacker.scenarioType" -}}
{{- define "nussknacker.streamingScenarioType" -}}
{{- if eq .Values.nussknacker.mode "flink" -}}
StreamMetaData
{{- else if eq .Values.nussknacker.mode "streaming-lite" -}}
{{- else if eq .Values.nussknacker.mode "lite-k8s" -}}
LiteStreamMetaData
{{- else if eq .Values.nussknacker.mode "request-response" -}}
RequestResponseMetaData
{{- end -}}
{{- end -}}

Expand Down
Loading

0 comments on commit 5dfd18a

Please sign in to comment.