From e08c14e3f7375fb4a19f84ab777055441d8ffda6 Mon Sep 17 00:00:00 2001 From: bmaidics Date: Thu, 25 Apr 2024 18:32:35 +0200 Subject: [PATCH] Use filesystem catalog instead of inline for async/openapi+grpc examples (#123) --- grpc.echo/values.yaml | 2 + grpc.echo/zilla.yaml | 17 +- grpc.kafka.echo/values.yaml | 2 + grpc.kafka.echo/zilla.yaml | 17 +- grpc.kafka.fanout/values.yaml | 2 + grpc.kafka.fanout/zilla.yaml | 17 +- grpc.kafka.proxy/values.yaml | 2 + grpc.kafka.proxy/zilla.yaml | 17 +- grpc.proxy/values.yaml | 2 + grpc.proxy/zilla.yaml | 17 +- .../docker/compose/docker-compose.yaml | 2 + mqtt.kafka.asyncapi.proxy/k8s/helm/setup.sh | 4 +- .../specs/kafka-asyncapi.yaml | 66 ++++ .../specs/mqtt-asyncapi.yaml | 277 ++++++++++++++ mqtt.kafka.asyncapi.proxy/zilla.yaml | 349 ++---------------- mqtt.proxy.asyncapi/mqtt-asyncapi.yaml | 62 ++++ mqtt.proxy.asyncapi/setup.sh | 3 +- mqtt.proxy.asyncapi/values.yaml | 6 + mqtt.proxy.asyncapi/zilla.yaml | 82 +--- .../docker/compose/docker-compose.yaml | 1 + .../specs/{schema.yaml => petstore.yaml} | 0 openapi.proxy/zilla.yaml | 94 +---- 22 files changed, 541 insertions(+), 500 deletions(-) create mode 100644 mqtt.kafka.asyncapi.proxy/specs/kafka-asyncapi.yaml create mode 100644 mqtt.kafka.asyncapi.proxy/specs/mqtt-asyncapi.yaml create mode 100644 mqtt.proxy.asyncapi/mqtt-asyncapi.yaml rename openapi.proxy/specs/{schema.yaml => petstore.yaml} (100%) diff --git a/grpc.echo/values.yaml b/grpc.echo/values.yaml index c7a99408..5e0ecccb 100644 --- a/grpc.echo/values.yaml +++ b/grpc.echo/values.yaml @@ -1,6 +1,8 @@ extraEnv: - name: KEYSTORE_PASSWORD value: generated + - name: ZILLA_INCUBATOR_ENABLED + value: "true" livenessProbePort: 7153 readinessProbePort: 7153 diff --git a/grpc.echo/zilla.yaml b/grpc.echo/zilla.yaml index 574d1f7e..0292faa9 100644 --- a/grpc.echo/zilla.yaml +++ b/grpc.echo/zilla.yaml @@ -1,4 +1,11 @@ name: example +catalogs: + host_filesystem: + type: filesystem + options: + subjects: + echo: + path: proto/echo.proto vaults: my_servers: type: filesystem @@ -47,9 +54,9 @@ bindings: north_grpc_server: type: grpc kind: server - options: - services: - - proto/echo.proto + catalog: + host_filesystem: + - subject: echo routes: - when: - method: example.EchoService/* @@ -57,3 +64,7 @@ bindings: north_echo_server: type: echo kind: server +telemetry: + exporters: + stdout_exporter: + type: stdout diff --git a/grpc.kafka.echo/values.yaml b/grpc.kafka.echo/values.yaml index c7a99408..5e0ecccb 100644 --- a/grpc.kafka.echo/values.yaml +++ b/grpc.kafka.echo/values.yaml @@ -1,6 +1,8 @@ extraEnv: - name: KEYSTORE_PASSWORD value: generated + - name: ZILLA_INCUBATOR_ENABLED + value: "true" livenessProbePort: 7153 readinessProbePort: 7153 diff --git a/grpc.kafka.echo/zilla.yaml b/grpc.kafka.echo/zilla.yaml index 9f24b537..245f2c94 100644 --- a/grpc.kafka.echo/zilla.yaml +++ b/grpc.kafka.echo/zilla.yaml @@ -1,4 +1,11 @@ name: example +catalogs: + host_filesystem: + type: filesystem + options: + subjects: + echo: + path: proto/echo.proto vaults: my_servers: type: filesystem @@ -47,9 +54,9 @@ bindings: north_grpc_server: type: grpc kind: server - options: - services: - - proto/echo.proto + catalog: + host_filesystem: + - subject: echo routes: - when: - method: example.EchoService/* @@ -90,3 +97,7 @@ bindings: routes: - when: - cidr: 0.0.0.0/0 +telemetry: + exporters: + stdout_exporter: + type: stdout diff --git a/grpc.kafka.fanout/values.yaml b/grpc.kafka.fanout/values.yaml index 7c7a38e7..5b4de1b8 100644 --- a/grpc.kafka.fanout/values.yaml +++ b/grpc.kafka.fanout/values.yaml @@ -1,6 +1,8 @@ extraEnv: - name: KEYSTORE_PASSWORD value: generated + - name: ZILLA_INCUBATOR_ENABLED + value: "true" livenessProbePort: 7153 readinessProbePort: 7153 diff --git a/grpc.kafka.fanout/zilla.yaml b/grpc.kafka.fanout/zilla.yaml index bf66db29..5a4de081 100644 --- a/grpc.kafka.fanout/zilla.yaml +++ b/grpc.kafka.fanout/zilla.yaml @@ -1,4 +1,11 @@ name: example +catalogs: + host_filesystem: + type: filesystem + options: + subjects: + fanout: + path: proto/fanout.proto vaults: my_servers: type: filesystem @@ -44,9 +51,9 @@ bindings: north_grpc_server: type: grpc kind: server - options: - services: - - proto/fanout.proto + catalog: + host_filesystem: + - subject: fanout routes: - when: - method: example.FanoutService/* @@ -82,3 +89,7 @@ bindings: routes: - when: - cidr: 0.0.0.0/0 +telemetry: + exporters: + stdout_exporter: + type: stdout diff --git a/grpc.kafka.proxy/values.yaml b/grpc.kafka.proxy/values.yaml index 7c7a38e7..5b4de1b8 100644 --- a/grpc.kafka.proxy/values.yaml +++ b/grpc.kafka.proxy/values.yaml @@ -1,6 +1,8 @@ extraEnv: - name: KEYSTORE_PASSWORD value: generated + - name: ZILLA_INCUBATOR_ENABLED + value: "true" livenessProbePort: 7153 readinessProbePort: 7153 diff --git a/grpc.kafka.proxy/zilla.yaml b/grpc.kafka.proxy/zilla.yaml index 3b9bc49b..fcfa5fc2 100644 --- a/grpc.kafka.proxy/zilla.yaml +++ b/grpc.kafka.proxy/zilla.yaml @@ -1,5 +1,12 @@ --- name: example +catalogs: + host_filesystem: + type: filesystem + options: + subjects: + echo: + path: proto/echo.proto vaults: my_servers: type: filesystem @@ -45,9 +52,9 @@ bindings: north_grpc_server: type: grpc kind: server - options: - services: - - proto/echo.proto + catalog: + host_filesystem: + - subject: echo routes: - when: - method: example.EchoService/* @@ -120,3 +127,7 @@ bindings: options: host: grpc-echo port: 8080 +telemetry: + exporters: + stdout_exporter: + type: stdout diff --git a/grpc.proxy/values.yaml b/grpc.proxy/values.yaml index 7c7a38e7..5b4de1b8 100644 --- a/grpc.proxy/values.yaml +++ b/grpc.proxy/values.yaml @@ -1,6 +1,8 @@ extraEnv: - name: KEYSTORE_PASSWORD value: generated + - name: ZILLA_INCUBATOR_ENABLED + value: "true" livenessProbePort: 7153 readinessProbePort: 7153 diff --git a/grpc.proxy/zilla.yaml b/grpc.proxy/zilla.yaml index 1166196c..372a8a7a 100644 --- a/grpc.proxy/zilla.yaml +++ b/grpc.proxy/zilla.yaml @@ -1,5 +1,12 @@ --- name: example +catalogs: + host_filesystem: + type: filesystem + options: + subjects: + echo: + path: proto/echo.proto vaults: my_servers: type: filesystem @@ -45,9 +52,9 @@ bindings: north_grpc_server: type: grpc kind: server - options: - services: - - proto/echo.proto + catalog: + host_filesystem: + - subject: echo routes: - when: - method: example.EchoService/* @@ -69,3 +76,7 @@ bindings: options: host: grpc-echo port: 8080 +telemetry: + exporters: + stdout_exporter: + type: stdout diff --git a/mqtt.kafka.asyncapi.proxy/docker/compose/docker-compose.yaml b/mqtt.kafka.asyncapi.proxy/docker/compose/docker-compose.yaml index 2412f41b..333a4d66 100644 --- a/mqtt.kafka.asyncapi.proxy/docker/compose/docker-compose.yaml +++ b/mqtt.kafka.asyncapi.proxy/docker/compose/docker-compose.yaml @@ -14,6 +14,8 @@ services: ZILLA_INCUBATOR_ENABLED: "true" volumes: - ../../zilla.yaml:/etc/zilla/zilla.yaml + - ../../specs/mqtt-asyncapi.yaml:/etc/zilla/specs/mqtt-asyncapi.yaml + - ../../specs/kafka-asyncapi.yaml:/etc/zilla/specs/kafka-asyncapi.yaml command: start -v -e networks: diff --git a/mqtt.kafka.asyncapi.proxy/k8s/helm/setup.sh b/mqtt.kafka.asyncapi.proxy/k8s/helm/setup.sh index 083329cd..d82dc5b4 100755 --- a/mqtt.kafka.asyncapi.proxy/k8s/helm/setup.sh +++ b/mqtt.kafka.asyncapi.proxy/k8s/helm/setup.sh @@ -14,7 +14,9 @@ echo "Installing $ZILLA_CHART to $NAMESPACE with Kafka at $KAFKA_HOST:$KAFKA_POR helm upgrade --install zilla $ZILLA_CHART --namespace $NAMESPACE --create-namespace --wait \ --values values.yaml \ --set extraEnv[1].value="\"$KAFKA_HOST\"",extraEnv[2].value="\"$KAFKA_PORT\"" \ - --set-file zilla\\.yaml=../../zilla.yaml + --set-file zilla\\.yaml=../../zilla.yaml \ + --set-file configMaps.specs.data.mqtt-asyncapi\\.yaml=../../specs/mqtt-asyncapi.yaml \ + --set-file configMaps.specs.data.kafka-asyncapi\\.yaml=../../specs/kafka-asyncapi.yaml # Create the mqtt topics in Kafka kubectl run kafka-init-pod --image=bitnami/kafka:3.2 --namespace $NAMESPACE --rm --restart=Never -i -t -- /bin/sh -c " diff --git a/mqtt.kafka.asyncapi.proxy/specs/kafka-asyncapi.yaml b/mqtt.kafka.asyncapi.proxy/specs/kafka-asyncapi.yaml new file mode 100644 index 00000000..10893728 --- /dev/null +++ b/mqtt.kafka.asyncapi.proxy/specs/kafka-asyncapi.yaml @@ -0,0 +1,66 @@ +# +# Copyright 2021-2023 Aklivity Inc. +# +# Aklivity licenses this file to you under the Apache License, +# version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# + +asyncapi: 3.0.0 +info: + title: Zilla Kafka Proxy + version: 1.0.0 + license: + name: Aklivity Community License +servers: + plain: + host: host.docker.internal:9092 + protocol: kafka + +operations: + onStreetlightData: + action: receive + channel: + $ref: '#/channels/streetlightData' + toStreetlightData: + action: send + channel: + $ref: '#/channels/streetlightData' + +channels: + streetlightData: + description: This channel contains a message for streetlights. + address: streetlights + messages: + streetlightData: + $ref: '#/components/messages/streetlightData' + mqttSessions: + description: This channel contains MQTT sessions. + address: mqtt-sessions + mqttMessages: + description: This channel contains MQTT messages. + address: mqtt-messages + mqttRetained: + description: This channel contains MQTT retained messages. + address: mqtt-retained + +components: + messages: + streetlightData: + payload: + type: object + properties: + streetlightId: + type: integer + description: This property describes the id of the streetlight + message: + type: string + description: This property describes message of the streetlight diff --git a/mqtt.kafka.asyncapi.proxy/specs/mqtt-asyncapi.yaml b/mqtt.kafka.asyncapi.proxy/specs/mqtt-asyncapi.yaml new file mode 100644 index 00000000..6cf176fd --- /dev/null +++ b/mqtt.kafka.asyncapi.proxy/specs/mqtt-asyncapi.yaml @@ -0,0 +1,277 @@ +# +# Copyright 2021-2023 Aklivity Inc. +# +# Aklivity licenses this file to you under the Apache License, +# version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# + +asyncapi: 3.0.0 +info: + title: Streetlights MQTT API + version: 1.0.0 + license: + name: Aklivity Community License +defaultContentType: application/json +servers: + production: + host: 'localhost:{port}' + protocol: mqtt + description: Test broker + variables: + port: + description: Secure connection (TLS) is available through port 8883. + default: '7183' + enum: + - '7183' + security: + - $ref: '#/components/securitySchemes/apiKey' + - type: oauth2 + description: Flows to support OAuth 2.0 + flows: + implicit: + authorizationUrl: 'https://authserver.example/auth' + availableScopes: + 'streetlights:on': Ability to switch lights on + 'streetlights:off': Ability to switch lights off + 'streetlights:dim': Ability to dim the lights + password: + tokenUrl: 'https://authserver.example/token' + availableScopes: + 'streetlights:on': Ability to switch lights on + 'streetlights:off': Ability to switch lights off + 'streetlights:dim': Ability to dim the lights + clientCredentials: + tokenUrl: 'https://authserver.example/token' + availableScopes: + 'streetlights:on': Ability to switch lights on + 'streetlights:off': Ability to switch lights off + 'streetlights:dim': Ability to dim the lights + authorizationCode: + authorizationUrl: 'https://authserver.example/auth' + tokenUrl: 'https://authserver.example/token' + refreshUrl: 'https://authserver.example/refresh' + availableScopes: + 'streetlights:on': Ability to switch lights on + 'streetlights:off': Ability to switch lights off + 'streetlights:dim': Ability to dim the lights + scopes: + - 'streetlights:on' + - 'streetlights:off' + - 'streetlights:dim' + - $ref: '#/components/securitySchemes/openIdConnectWellKnown' + tags: + - name: 'env:production' + description: This environment is meant for production use case + - name: 'kind:remote' + description: This server is a remote server. Not exposed by the application + - name: 'visibility:public' + description: This resource is public and available to everyone +channels: + lightingMeasured: + address: 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured' + messages: + lightMeasured: + $ref: '#/components/messages/lightMeasured' + description: The topic on which measured values may be produced and consumed. + parameters: + streetlightId: + $ref: '#/components/parameters/streetlightId' + lightTurnOn: + address: 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on' + messages: + turnOn: + $ref: '#/components/messages/turnOnOff' + parameters: + streetlightId: + $ref: '#/components/parameters/streetlightId' + lightTurnOff: + address: 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/off' + messages: + turnOff: + $ref: '#/components/messages/turnOnOff' + parameters: + streetlightId: + $ref: '#/components/parameters/streetlightId' + lightsDim: + address: 'smartylighting/streetlights/1/0/action/{streetlightId}/dim' + messages: + dimLight: + $ref: '#/components/messages/dimLight' + parameters: + streetlightId: + $ref: '#/components/parameters/streetlightId' +operations: + receiveLightMeasurement: + action: receive + channel: + $ref: '#/channels/lightingMeasured' + summary: >- + Inform about environmental lighting conditions of a particular + streetlight. + traits: + - $ref: '#/components/operationTraits/mqtt' + messages: + - $ref: '#/channels/lightingMeasured/messages/lightMeasured' + sendLightMeasurement: + action: send + channel: + $ref: '#/channels/lightingMeasured' + summary: >- + Inform about environmental lighting conditions of a particular + streetlight. + traits: + - $ref: '#/components/operationTraits/mqtt' + messages: + - $ref: '#/channels/lightingMeasured/messages/lightMeasured' + turnOn: + action: send + channel: + $ref: '#/channels/lightTurnOn' + traits: + - $ref: '#/components/operationTraits/mqtt' + messages: + - $ref: '#/channels/lightTurnOn/messages/turnOn' + turnOff: + action: send + channel: + $ref: '#/channels/lightTurnOff' + traits: + - $ref: '#/components/operationTraits/mqtt' + messages: + - $ref: '#/channels/lightTurnOff/messages/turnOff' + dimLight: + action: send + channel: + $ref: '#/channels/lightsDim' + traits: + - $ref: '#/components/operationTraits/mqtt' + messages: + - $ref: '#/channels/lightsDim/messages/dimLight' +components: + messages: + lightMeasured: + name: lightMeasured + title: Light measured + summary: >- + Inform about environmental lighting conditions of a particular + streetlight. + contentType: application/json + traits: + - $ref: '#/components/messageTraits/commonHeaders' + payload: + $ref: '#/components/schemas/lightMeasuredPayload' + turnOnOff: + name: turnOnOff + title: Turn on/off + summary: Command a particular streetlight to turn the lights on or off. + traits: + - $ref: '#/components/messageTraits/commonHeaders' + payload: + $ref: '#/components/schemas/turnOnOffPayload' + dimLight: + name: dimLight + title: Dim light + summary: Command a particular streetlight to dim the lights. + traits: + - $ref: '#/components/messageTraits/commonHeaders' + payload: + $ref: '#/components/schemas/dimLightPayload' + schemas: + lightMeasuredPayload: + type: object + properties: + lumens: + type: integer + minimum: 0 + description: Light intensity measured in lumens. + sentAt: + $ref: '#/components/schemas/sentAt' + turnOnOffPayload: + type: object + properties: + command: + type: string + enum: + - 'on' + - 'off' + description: Whether to turn on or off the light. + sentAt: + $ref: '#/components/schemas/sentAt' + dimLightPayload: + type: object + properties: + percentage: + type: integer + description: Percentage to which the light should be dimmed to. + minimum: 0 + maximum: 100 + sentAt: + $ref: '#/components/schemas/sentAt' + sentAt: + type: string + format: date-time + description: Date and time when the message was sent. + securitySchemes: + apiKey: + type: apiKey + in: user + description: Provide your API key as the user and leave the password empty. + supportedOauthFlows: + type: oauth2 + description: Flows to support OAuth 2.0 + flows: + implicit: + authorizationUrl: 'https://authserver.example/auth' + availableScopes: + 'streetlights:on': Ability to switch lights on + 'streetlights:off': Ability to switch lights off + 'streetlights:dim': Ability to dim the lights + password: + tokenUrl: 'https://authserver.example/token' + availableScopes: + 'streetlights:on': Ability to switch lights on + 'streetlights:off': Ability to switch lights off + 'streetlights:dim': Ability to dim the lights + clientCredentials: + tokenUrl: 'https://authserver.example/token' + availableScopes: + 'streetlights:on': Ability to switch lights on + 'streetlights:off': Ability to switch lights off + 'streetlights:dim': Ability to dim the lights + authorizationCode: + authorizationUrl: 'https://authserver.example/auth' + tokenUrl: 'https://authserver.example/token' + refreshUrl: 'https://authserver.example/refresh' + availableScopes: + 'streetlights:on': Ability to switch lights on + 'streetlights:off': Ability to switch lights off + 'streetlights:dim': Ability to dim the lights + openIdConnectWellKnown: + type: openIdConnect + openIdConnectUrl: 'https://authserver.example/.well-known' + parameters: + streetlightId: + description: The ID of the streetlight. + messageTraits: + commonHeaders: + headers: + type: object + properties: + my-app-header: + type: integer + minimum: 0 + maximum: 100 + operationTraits: + mqtt: + bindings: + mqtt: + qos: 1 diff --git a/mqtt.kafka.asyncapi.proxy/zilla.yaml b/mqtt.kafka.asyncapi.proxy/zilla.yaml index 74c3a53b..7603842f 100644 --- a/mqtt.kafka.asyncapi.proxy/zilla.yaml +++ b/mqtt.kafka.asyncapi.proxy/zilla.yaml @@ -1,350 +1,39 @@ --- name: zilla-mqtt-kafka-broker catalogs: - catalog0: - type: inline + host_filesystem: + type: filesystem options: subjects: mqtt: - schema: | - asyncapi: 3.0.0 - info: - title: Streetlights MQTT API - version: 1.0.0 - license: - name: Aklivity Community License - defaultContentType: application/json - servers: - production: - host: 'localhost:{port}' - protocol: mqtt - description: Test broker - variables: - port: - description: Secure connection (TLS) is available through port 8883. - default: '7183' - enum: - - '7183' - security: - - $ref: '#/components/securitySchemes/apiKey' - - type: oauth2 - description: Flows to support OAuth 2.0 - flows: - implicit: - authorizationUrl: 'https://authserver.example/auth' - availableScopes: - 'streetlights:on': Ability to switch lights on - 'streetlights:off': Ability to switch lights off - 'streetlights:dim': Ability to dim the lights - password: - tokenUrl: 'https://authserver.example/token' - availableScopes: - 'streetlights:on': Ability to switch lights on - 'streetlights:off': Ability to switch lights off - 'streetlights:dim': Ability to dim the lights - clientCredentials: - tokenUrl: 'https://authserver.example/token' - availableScopes: - 'streetlights:on': Ability to switch lights on - 'streetlights:off': Ability to switch lights off - 'streetlights:dim': Ability to dim the lights - authorizationCode: - authorizationUrl: 'https://authserver.example/auth' - tokenUrl: 'https://authserver.example/token' - refreshUrl: 'https://authserver.example/refresh' - availableScopes: - 'streetlights:on': Ability to switch lights on - 'streetlights:off': Ability to switch lights off - 'streetlights:dim': Ability to dim the lights - scopes: - - 'streetlights:on' - - 'streetlights:off' - - 'streetlights:dim' - - $ref: '#/components/securitySchemes/openIdConnectWellKnown' - tags: - - name: 'env:production' - description: This environment is meant for production use case - - name: 'kind:remote' - description: This server is a remote server. Not exposed by the application - - name: 'visibility:public' - description: This resource is public and available to everyone - channels: - lightingMeasured: - address: 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured' - messages: - lightMeasured: - $ref: '#/components/messages/lightMeasured' - description: The topic on which measured values may be produced and consumed. - parameters: - streetlightId: - $ref: '#/components/parameters/streetlightId' - lightTurnOn: - address: 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on' - messages: - turnOn: - $ref: '#/components/messages/turnOnOff' - parameters: - streetlightId: - $ref: '#/components/parameters/streetlightId' - lightTurnOff: - address: 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/off' - messages: - turnOff: - $ref: '#/components/messages/turnOnOff' - parameters: - streetlightId: - $ref: '#/components/parameters/streetlightId' - lightsDim: - address: 'smartylighting/streetlights/1/0/action/{streetlightId}/dim' - messages: - dimLight: - $ref: '#/components/messages/dimLight' - parameters: - streetlightId: - $ref: '#/components/parameters/streetlightId' - operations: - receiveLightMeasurement: - action: receive - channel: - $ref: '#/channels/lightingMeasured' - summary: >- - Inform about environmental lighting conditions of a particular - streetlight. - traits: - - $ref: '#/components/operationTraits/mqtt' - messages: - - $ref: '#/channels/lightingMeasured/messages/lightMeasured' - sendLightMeasurement: - action: send - channel: - $ref: '#/channels/lightingMeasured' - summary: >- - Inform about environmental lighting conditions of a particular - streetlight. - traits: - - $ref: '#/components/operationTraits/mqtt' - messages: - - $ref: '#/channels/lightingMeasured/messages/lightMeasured' - turnOn: - action: send - channel: - $ref: '#/channels/lightTurnOn' - traits: - - $ref: '#/components/operationTraits/mqtt' - messages: - - $ref: '#/channels/lightTurnOn/messages/turnOn' - turnOff: - action: send - channel: - $ref: '#/channels/lightTurnOff' - traits: - - $ref: '#/components/operationTraits/mqtt' - messages: - - $ref: '#/channels/lightTurnOff/messages/turnOff' - dimLight: - action: send - channel: - $ref: '#/channels/lightsDim' - traits: - - $ref: '#/components/operationTraits/mqtt' - messages: - - $ref: '#/channels/lightsDim/messages/dimLight' - components: - messages: - lightMeasured: - name: lightMeasured - title: Light measured - summary: >- - Inform about environmental lighting conditions of a particular - streetlight. - contentType: application/json - traits: - - $ref: '#/components/messageTraits/commonHeaders' - payload: - $ref: '#/components/schemas/lightMeasuredPayload' - turnOnOff: - name: turnOnOff - title: Turn on/off - summary: Command a particular streetlight to turn the lights on or off. - traits: - - $ref: '#/components/messageTraits/commonHeaders' - payload: - $ref: '#/components/schemas/turnOnOffPayload' - dimLight: - name: dimLight - title: Dim light - summary: Command a particular streetlight to dim the lights. - traits: - - $ref: '#/components/messageTraits/commonHeaders' - payload: - $ref: '#/components/schemas/dimLightPayload' - schemas: - lightMeasuredPayload: - type: object - properties: - lumens: - type: integer - minimum: 0 - description: Light intensity measured in lumens. - sentAt: - $ref: '#/components/schemas/sentAt' - turnOnOffPayload: - type: object - properties: - command: - type: string - enum: - - 'on' - - 'off' - description: Whether to turn on or off the light. - sentAt: - $ref: '#/components/schemas/sentAt' - dimLightPayload: - type: object - properties: - percentage: - type: integer - description: Percentage to which the light should be dimmed to. - minimum: 0 - maximum: 100 - sentAt: - $ref: '#/components/schemas/sentAt' - sentAt: - type: string - format: date-time - description: Date and time when the message was sent. - securitySchemes: - apiKey: - type: apiKey - in: user - description: Provide your API key as the user and leave the password empty. - supportedOauthFlows: - type: oauth2 - description: Flows to support OAuth 2.0 - flows: - implicit: - authorizationUrl: 'https://authserver.example/auth' - availableScopes: - 'streetlights:on': Ability to switch lights on - 'streetlights:off': Ability to switch lights off - 'streetlights:dim': Ability to dim the lights - password: - tokenUrl: 'https://authserver.example/token' - availableScopes: - 'streetlights:on': Ability to switch lights on - 'streetlights:off': Ability to switch lights off - 'streetlights:dim': Ability to dim the lights - clientCredentials: - tokenUrl: 'https://authserver.example/token' - availableScopes: - 'streetlights:on': Ability to switch lights on - 'streetlights:off': Ability to switch lights off - 'streetlights:dim': Ability to dim the lights - authorizationCode: - authorizationUrl: 'https://authserver.example/auth' - tokenUrl: 'https://authserver.example/token' - refreshUrl: 'https://authserver.example/refresh' - availableScopes: - 'streetlights:on': Ability to switch lights on - 'streetlights:off': Ability to switch lights off - 'streetlights:dim': Ability to dim the lights - openIdConnectWellKnown: - type: openIdConnect - openIdConnectUrl: 'https://authserver.example/.well-known' - parameters: - streetlightId: - description: The ID of the streetlight. - messageTraits: - commonHeaders: - headers: - type: object - properties: - my-app-header: - type: integer - minimum: 0 - maximum: 100 - operationTraits: - mqtt: - bindings: - mqtt: - qos: 1 + path: specs/mqtt-asyncapi.yaml kafka: - schema: | - asyncapi: 3.0.0 - info: - title: Zilla Kafka Proxy - version: 1.0.0 - license: - name: Aklivity Community License - servers: - plain: - host: host.docker.internal:9092 - protocol: kafka - - operations: - onStreetlightData: - action: receive - channel: - $ref: '#/channels/streetlightData' - toStreetlightData: - action: send - channel: - $ref: '#/channels/streetlightData' - - channels: - streetlightData: - description: This channel contains a message for streetlights. - address: streetlights - messages: - streetlightData: - $ref: '#/components/messages/streetlightData' - mqttSessions: - description: This channel contains MQTT sessions. - address: mqtt-sessions - mqttMessages: - description: This channel contains MQTT messages. - address: mqtt-messages - mqttRetained: - description: This channel contains MQTT retained messages. - address: mqtt-retained - - components: - messages: - streetlightData: - payload: - type: object - properties: - streetlightId: - type: integer - description: This property describes the id of the streetlight - message: - type: string - description: This property describes message of the streetlight + path: specs/kafka-asyncapi.yaml bindings: - asyncapi_mqtt0: + north_mqtt_server: type: asyncapi kind: server options: specs: mqtt_api: catalog: - catalog0: + host_filesystem: subject: mqtt version: latest - exit: asyncapi_proxy0 - asyncapi_proxy0: + exit: south_kafka_proxy + south_kafka_proxy: type: asyncapi kind: proxy options: specs: mqtt_api: catalog: - catalog0: + host_filesystem: subject: mqtt version: latest kafka_api: catalog: - catalog0: + host_filesystem: subject: kafka version: latest mqtt-kafka: @@ -356,45 +45,49 @@ bindings: - when: - api-id: mqtt_api operation-id: turnOn - exit: asyncapi_kafka0 + exit: south_kafka_client with: api-id: kafka_api operation-id: toStreetlightData - when: - api-id: mqtt_api operation-id: receiveLightMeasurement - exit: asyncapi_kafka0 + exit: south_kafka_client with: api-id: kafka_api operation-id: onStreetlightData - when: - api-id: mqtt_api operation-id: sendLightMeasurement - exit: asyncapi_kafka0 + exit: south_kafka_client with: api-id: kafka_api operation-id: toStreetlightData - when: - api-id: mqtt_api operation-id: turnOff - exit: asyncapi_kafka0 + exit: south_kafka_client with: api-id: kafka_api operation-id: toStreetlightData - when: - api-id: mqtt_api operation-id: dimLight - exit: asyncapi_kafka0 + exit: south_kafka_client with: api-id: kafka_api operation-id: toStreetlightData - asyncapi_kafka0: + south_kafka_client: type: asyncapi kind: client options: specs: kafka_api: catalog: - catalog0: + host_filesystem: subject: kafka version: latest +telemetry: + exporters: + stdout_exporter: + type: stdout diff --git a/mqtt.proxy.asyncapi/mqtt-asyncapi.yaml b/mqtt.proxy.asyncapi/mqtt-asyncapi.yaml new file mode 100644 index 00000000..ddc5f642 --- /dev/null +++ b/mqtt.proxy.asyncapi/mqtt-asyncapi.yaml @@ -0,0 +1,62 @@ +asyncapi: 3.0.0 +info: + title: Zilla MQTT Proxy + version: 1.0.0 + license: + name: Aklivity Community License +servers: + plain: + host: localhost:7183 + protocol: mqtt +defaultContentType: application/json + +channels: + smartylighting: + address: "smartylighting/streetlights/1/0/event/1/lighting/measured" + title: MQTT Topic to produce & consume topic. + messages: + item: + $ref: '#/components/messages/item' + +operations: + sendEvents: + action: send + channel: + $ref: '#/channels/smartylighting' + + receiveEvents: + action: receive + channel: + $ref: '#/channels/smartylighting' + +components: + messages: + item: + name: event + title: An event + headers: + type: object + properties: + idempotency-key: + description: Unique identifier for a given event + type: string + id: + description: Street Light ID + type: string + contentType: application/json + payload: + type: object + properties: + item: + $ref: "#/components/schemas/item" + schemas: + item: + type: object + properties: + id: + type: string + status: + type: string + required: + - id + - status diff --git a/mqtt.proxy.asyncapi/setup.sh b/mqtt.proxy.asyncapi/setup.sh index 9ab9e1ec..252a5b6a 100755 --- a/mqtt.proxy.asyncapi/setup.sh +++ b/mqtt.proxy.asyncapi/setup.sh @@ -6,7 +6,8 @@ ZILLA_CHART=oci://ghcr.io/aklivity/charts/zilla NAMESPACE=mqtt-proxy-asyncapi helm upgrade --install zilla $ZILLA_CHART --namespace $NAMESPACE --create-namespace --wait \ --values values.yaml \ - --set-file zilla\\.yaml=zilla.yaml + --set-file zilla\\.yaml=zilla.yaml \ + --set-file configMaps.asyncapi.data.mqtt-asyncapi\\.yaml=mqtt-asyncapi.yaml # Install mosquitto mqtt broker to the Kubernetes cluster with helm and wait for the pod to start up helm upgrade --install mosquitto chart --namespace $NAMESPACE --create-namespace --wait diff --git a/mqtt.proxy.asyncapi/values.yaml b/mqtt.proxy.asyncapi/values.yaml index 41704a6c..84b38216 100644 --- a/mqtt.proxy.asyncapi/values.yaml +++ b/mqtt.proxy.asyncapi/values.yaml @@ -3,6 +3,10 @@ extraEnv: value: mosquitto - name: MOSQUITTO_BROKER_PORT value: "1883" + - name: ZILLA_INCUBATOR_ENABLED + value: "true" + - name: JAVA_OPTIONS + value: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 livenessProbePort: 7183 readinessProbePort: 7183 @@ -11,3 +15,5 @@ service: ports: - port: 7183 name: mqtt + - port: 5005 + name: debug diff --git a/mqtt.proxy.asyncapi/zilla.yaml b/mqtt.proxy.asyncapi/zilla.yaml index 31080f93..863c79ec 100644 --- a/mqtt.proxy.asyncapi/zilla.yaml +++ b/mqtt.proxy.asyncapi/zilla.yaml @@ -1,96 +1,38 @@ --- name: zilla-mqtt-kafka-broker catalogs: - catalog0: - type: inline + host_filesystem: + type: filesystem options: subjects: smartylighting: - schema: | - asyncapi: 3.0.0 - info: - title: Zilla MQTT Proxy - version: 1.0.0 - license: - name: Aklivity Community License - servers: - plain: - host: localhost:7183 - protocol: mqtt - defaultContentType: application/json - - channels: - smartylighting: - address: "smartylighting/streetlights/1/0/event/1/lighting/measured" - title: MQTT Topic to produce & consume topic. - messages: - item: - $ref: '#/components/messages/item' - - operations: - sendEvents: - action: send - channel: - $ref: '#/channels/smartylighting' - - receiveEvents: - action: receive - channel: - $ref: '#/channels/smartylighting' - - components: - messages: - item: - name: event - title: An event - headers: - type: object - properties: - idempotency-key: - description: Unique identifier for a given event - type: string - id: - description: Street Light ID - type: string - contentType: application/json - payload: - type: object - properties: - item: - $ref: "#/components/schemas/item" - schemas: - item: - type: object - properties: - id: - type: string - status: - type: string - required: - - id - - status + path: asyncapi/mqtt-asyncapi.yaml bindings: - asyncapi_server: + mqtt_proxy_server: type: asyncapi kind: server options: specs: my-asyncapi-spec: catalog: - catalog0: + host_filesystem: subject: smartylighting version: latest - exit: asyncapi_client - asyncapi_client: + exit: mqtt_proxy_client + mqtt_proxy_client: type: asyncapi kind: client options: specs: my-asyncapi-spec: catalog: - catalog0: + host_filesystem: subject: smartylighting version: latest tcp: host: ${{env.MOSQUITTO_BROKER_HOST}} port: ${{env.MOSQUITTO_BROKER_PORT}} +telemetry: + exporters: + stdout_exporter: + type: stdout diff --git a/openapi.proxy/docker/compose/docker-compose.yaml b/openapi.proxy/docker/compose/docker-compose.yaml index 2208ed09..50303be0 100644 --- a/openapi.proxy/docker/compose/docker-compose.yaml +++ b/openapi.proxy/docker/compose/docker-compose.yaml @@ -10,6 +10,7 @@ services: environment: ZILLA_INCUBATOR_ENABLED: true volumes: + - ../../specs/petstore.yaml:/etc/zilla/petstore.yaml - ../../zilla.yaml:/etc/zilla/zilla.yaml command: start -v -e diff --git a/openapi.proxy/specs/schema.yaml b/openapi.proxy/specs/petstore.yaml similarity index 100% rename from openapi.proxy/specs/schema.yaml rename to openapi.proxy/specs/petstore.yaml diff --git a/openapi.proxy/zilla.yaml b/openapi.proxy/zilla.yaml index 0b5c6dfd..6bfbd3b6 100644 --- a/openapi.proxy/zilla.yaml +++ b/openapi.proxy/zilla.yaml @@ -1,92 +1,12 @@ --- name: zilla-openapi-proxy catalogs: - catalog0: - type: inline + host_filesystem: + type: filesystem options: subjects: petstore: - schema: | - --- - openapi: 3.0.0 - info: - version: 1.0.0 - title: Swagger Petstore - license: - name: MIT - servers: - - url: http://localhost:7114 - paths: - "/pets": - get: - summary: List all pets - operationId: listPets - tags: - - pets - responses: - '200': - description: A paged array of pets - content: - application/json: - schema: - "$ref": "#/components/schemas/Pets" - default: - description: unexpected error - content: - application/json: - schema: - "$ref": "#/components/schemas/Error" - post: - summary: Create a pet - operationId: createPets - tags: - - pets - requestBody: - content: - application/json: - schema: - "$ref": "#/components/schemas/Pet" - required: true - responses: - '201': - description: Null response - default: - description: unexpected error - content: - application/json: - schema: - "$ref": "#/components/schemas/Error" - components: - schemas: - Pet: - type: object - required: - - id - - name - properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string - Pets: - type: array - maxItems: 100 - items: - "$ref": "#/components/schemas/Pet" - Error: - type: object - required: - - code - - message - properties: - code: - type: integer - format: int32 - message: - type: string + path: petstore.yaml bindings: north_openapi_server: type: openapi @@ -95,7 +15,7 @@ bindings: specs: my-openapi-spec: catalog: - catalog0: + host_filesystem: subject: petstore version: latest exit: south_openapi_lcient @@ -106,10 +26,14 @@ bindings: specs: my-openapi-spec: catalog: - catalog0: + host_filesystem: subject: petstore version: latest tcp: host: openapi-mock port: - 5000 +telemetry: + exporters: + stdout_exporter: + type: stdout