From 865adda33c04a9e3ab30e8c3d7f31647b8eef05c Mon Sep 17 00:00:00 2001 From: Matthias Wessendorf Date: Wed, 2 Oct 2024 11:36:21 +0200 Subject: [PATCH] Adding s3 sqs sink (#8) :snake: adding s3 sqs sink Signed-off-by: Matthias Wessendorf --- aws-sqs-sink/README.adoc | 176 +++++++++++++++ aws-sqs-sink/pom.xml | 140 ++++++++++++ aws-sqs-sink/properties.adoc | 4 + aws-sqs-sink/src/main/docker/Dockerfile.jvm | 114 ++++++++++ .../src/main/docker/Dockerfile.legacy-jar | 110 ++++++++++ .../src/main/docker/Dockerfile.native | 44 ++++ .../src/main/docker/Dockerfile.native-micro | 47 ++++ .../src/main/kubernetes/kubernetes.yml | 17 ++ .../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++++++++++++ .../src/main/resources/META-INF/NOTICE.txt | 11 + .../src/main/resources/application.properties | 34 +++ .../resources/camel/kn-connector-sink.yaml | 34 +++ aws-sqs-sink/src/main/resources/knative.json | 14 ++ pom.xml | 1 + 14 files changed, 949 insertions(+) create mode 100644 aws-sqs-sink/README.adoc create mode 100644 aws-sqs-sink/pom.xml create mode 100644 aws-sqs-sink/properties.adoc create mode 100644 aws-sqs-sink/src/main/docker/Dockerfile.jvm create mode 100644 aws-sqs-sink/src/main/docker/Dockerfile.legacy-jar create mode 100644 aws-sqs-sink/src/main/docker/Dockerfile.native create mode 100644 aws-sqs-sink/src/main/docker/Dockerfile.native-micro create mode 100644 aws-sqs-sink/src/main/kubernetes/kubernetes.yml create mode 100644 aws-sqs-sink/src/main/resources/META-INF/LICENSE.txt create mode 100644 aws-sqs-sink/src/main/resources/META-INF/NOTICE.txt create mode 100644 aws-sqs-sink/src/main/resources/application.properties create mode 100644 aws-sqs-sink/src/main/resources/camel/kn-connector-sink.yaml create mode 100644 aws-sqs-sink/src/main/resources/knative.json diff --git a/aws-sqs-sink/README.adoc b/aws-sqs-sink/README.adoc new file mode 100644 index 0000000..5746334 --- /dev/null +++ b/aws-sqs-sink/README.adoc @@ -0,0 +1,176 @@ += Knative connector aws-sqs-sink + +Knative eventing connector based on https://camel.apache.org/camel-kamelets/[Apache Camel Kamelets]. +The connector project creates a container image that is pushed into a registry so the image can be referenced in a Kubernetes deployment. + +== Kamelet properties + +The kn-connector source images provides these properties that you can set (e.g. via environment properties on the deployment). + +.Kamelet properties +include::properties.adoc[] + +== Kubernetes manifest + +The build produces a Kubernetes manifest in (`target/kubernetes/kubernetes.yml`). +This manifest holds all resources required to run the application on your Kubernetes cluster. + +You can customize the Kubernetes resources in link:src/main/kubernetes/kubernetes.yml[src/main/kubernetes/kubernetes.yml]. +This is being used as a basis and Quarkus will generate the final manifest in `target/kubernetes/kubernetes.yml` during the build. + +The final Kubernetes manifest includes: + +* Service +* Deployment +* Trigger + +== Kamelet sink Pipe + +The sink consumes events from the Knative broker. +It uses an Apache Camel Pipe resource as the central piece of code to define how the Knative events are consumed and where the events get forwarded to. + +The Pipe is a YAML file located in link:src/main/resources/camel/kn-connector-sink.yaml[src/main/resources/camel/kn-connector-sink.yaml] + +.kn-connector-sink.yaml +[source,yaml] +---- +apiVersion: camel.apache.org/v1 +kind: Pipe +metadata: + name: kn-connector-aws-sqs-sink +spec: + source: + ref: + kind: Broker + apiVersion: eventing.knative.dev/v1 + name: default + properties: + type: "" + sink: + ref: + kind: Kamelet + apiVersion: camel.apache.org/v1 + name: aws-sqs-sink +---- + +This connector uses the https://camel.apache.org/camel-kamelets/aws-sqs-sink.html[aws-sqs-sink] Kamelet and consumes events from the Knative broker. + +The Pipe references a Knative broker as a source and connects to a Kamelet as a sink. + +The name of the broker is always `default` because the Knative Trigger resource is responsible for connecting the application to the Knative broker. +The Trigger decides when to call the application as it provides the events to the application based on the trigger configuration. + +This way the same container image can be used with different brokers and events (e.g. by adding filter criteria to the Trigger). +It is only a matter of configuring the Trigger resource that connects the application with the Knative broker. + +You can find a sample Trigger in link:src/main/kubernetes/kubernetes.yml[src/main/kubernetes/kubernetes.yml] + +[source,yaml] +---- +apiVersion: eventing.knative.dev/v1 +kind: Trigger +metadata: + annotations: + eventing.knative.dev/creator: kn-connectors + labels: + eventing.knative.dev/connector: aws-sqs-sink + eventing.knative.dev/broker: default + name: kn-connector-aws-sqs-sink +spec: + broker: default + subscriber: + ref: + apiVersion: v1 + kind: Service + name: kn-connector-aws-sqs-sink + uri: /events +---- + +== Configuration + +Each Kamelet defines a set of properties. +The user is able to customize these properties when running a connector deployment. + +=== Environment variables + +You can customize the properties via environment variables on the deployment: + +.Environment variables +include::properties.adoc[] + +The environment variables that overwrite properties on the Kamelet sink follow a naming convention: + +* CAMEL_KAMELET_{{KAMELET_NAME}}_{{PROPERTY_NAME}}={{PROPERTY_VALUE}} + +The name represents the name of the Kamelet sink as defined in the https://camel.apache.org/camel-kamelets/[Kamelet catalog]. + +The environment variables may be set as part of the Kubernetes deployment or as an alternative on the Knative ContainerSource: + +[source,yaml] +---- +apiVersion: sources.knative.dev/v1 +kind: ContainerSource +metadata: + name: kamelet-sink + namespace: knative-samples +spec: + template: + spec: + containers: + - image: quay.io/openshift-knative/kn-connector-aws-sqs-sink:1.0 + name: log + env: + - name: CAMEL_KAMELET_{{KAMELET_NAME}}_{{PROPERTY_NAME}} + value: "true" + - name: CAMEL_KAMELET_{{KAMELET_NAME}}_{{PROPERTY_NAME}} + value: "INFO" + sink: + ref: + apiVersion: eventing.knative.dev/v1 + kind: Broker + name: default +---- + +You can also set the environment variable on the running deployment: + +[source,shell] +---- +kubectl set env deployment/kn-connector-{{sink-name}} CAMEL_KAMELET_{{KAMELET_NAME}}_{{PROPERTY_NAME}}="true" +---- + +=== ConfigMap and Secret + +You may also mount a configmap/secret to overwrite Kamelet properties with values from the configmap/secret resource. + +As the Kamelet properties are configured viw environment variables on the ContainerSource you can also use values referencing a configmap or secret. + +[source,yaml] +---- +apiVersion: sources.knative.dev/v1 +kind: ContainerSource +metadata: + name: kamelet-sink +spec: + template: + spec: + containers: + - image: quay.io/openshift-knative/kn-connector-aws-sqs-sink:1.0 + name: log + env: + - name: CAMEL_KAMELET_{{KAMELET_NAME}}_{{PROPERTY_NAME}} + valueFrom: + secretKeyRef: + name: my-secret + key: my-property-value + sink: + ref: + apiVersion: eventing.knative.dev/v1 + kind: Broker + name: default +---- + +The example above references a secret called `my-secret` and loads the key `my-property-value`. + +== More configuration options + +For more information about Apache Camel Kamelets and their individual properties see https://camel.apache.org/camel-kamelets/. diff --git a/aws-sqs-sink/pom.xml b/aws-sqs-sink/pom.xml new file mode 100644 index 0000000..6558db5 --- /dev/null +++ b/aws-sqs-sink/pom.xml @@ -0,0 +1,140 @@ + + + + 4.0.0 + + + dev.knative.eventing + kn-connectors + 1.0-SNAPSHOT + ../pom.xml + + + kn-connector-aws-sqs-sink + Knative Connectors :: aws-sqs Sink + + + + org.apache.camel.quarkus + camel-quarkus-core + + + org.apache.camel.quarkus + camel-quarkus-platform-http + + + org.apache.camel.quarkus + camel-quarkus-microprofile-health + + + org.apache.camel.quarkus + camel-quarkus-kubernetes + + + + + io.quarkus + quarkus-container-image-jib + + + io.quarkus + quarkus-kubernetes + + + + + org.apache.camel.quarkus + camel-quarkus-kamelet + + + + + org.apache.camel.quarkus + camel-quarkus-aws2-sqs + + + + org.apache.camel.quarkus + camel-quarkus-yaml-dsl + + + + + org.apache.camel.quarkus + camel-quarkus-knative + + + org.apache.camel.quarkus + camel-quarkus-knative-producer + + + + org.apache.camel.kamelets + camel-kamelets-utils + + + org.apache.camel.kamelets + camel-kamelets + + + io.fabric8 + kubernetes-client + + + + + io.quarkus + quarkus-junit5 + test + + + org.citrusframework + citrus-quarkus + test + + + org.citrusframework + citrus-http + test + + + + + + + dev.knative.eventing + kn-connector-maven-plugin + ${project.version} + + aws-sqs-sink + + + + generate-connector-spec + process-classes + + generate + + + + + + ${quarkus.platform.group-id} + quarkus-maven-plugin + + + maven-compiler-plugin + ${compiler-plugin.version} + + + maven-surefire-plugin + ${surefire-plugin.version} + + + maven-failsafe-plugin + ${surefire-plugin.version} + + + + diff --git a/aws-sqs-sink/properties.adoc b/aws-sqs-sink/properties.adoc new file mode 100644 index 0000000..f7ccf52 --- /dev/null +++ b/aws-sqs-sink/properties.adoc @@ -0,0 +1,4 @@ +|=== +|Property |Required |EnvVar |Description + +|=== diff --git a/aws-sqs-sink/src/main/docker/Dockerfile.jvm b/aws-sqs-sink/src/main/docker/Dockerfile.jvm new file mode 100644 index 0000000..4532424 --- /dev/null +++ b/aws-sqs-sink/src/main/docker/Dockerfile.jvm @@ -0,0 +1,114 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF 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. +# + +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/code-with-quarkus-jvm . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-jvm +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. +# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 +# when running the container +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-jvm +# +# This image uses the `run-java.sh` script to run the application. +# This scripts computes the command line to execute your Java application, and +# includes memory/GC tuning. +# You can configure the behavior using the following environment properties: +# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") +# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options +# in JAVA_OPTS (example: "-Dsome.property=foo") +# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is +# used to calculate a default maximal heap memory based on a containers restriction. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio +# of the container available memory as set here. The default is `50` which means 50% +# of the available memory is used as an upper boundary. You can skip this mechanism by +# setting this value to `0` in which case no `-Xmx` option is added. +# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This +# is used to calculate a default initial heap memory based on the maximum heap memory. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio +# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` +# is used as the initial heap size. You can skip this mechanism by setting this value +# to `0` in which case no `-Xms` option is added (example: "25") +# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. +# This is used to calculate the maximum value of the initial heap memory. If used in +# a container without any memory constraints for the container then this option has +# no effect. If there is a memory constraint then `-Xms` is limited to the value set +# here. The default is 4096MB which means the calculated value of `-Xms` never will +# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") +# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output +# when things are happening. This option, if set to true, will set +# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). +# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: +# true"). +# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). +# - CONTAINER_CORE_LIMIT: A calculated core limit as described in +# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") +# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). +# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. +# (example: "20") +# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. +# (example: "40") +# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. +# (example: "4") +# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus +# previous GC times. (example: "90") +# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") +# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") +# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should +# contain the necessary JRE command-line options to specify the required GC, which +# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). +# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") +# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") +# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be +# accessed directly. (example: "foo.example.com,bar.example.com") +# +### +FROM registry.access.redhat.com/ubi8/openjdk-17:1.16 + +ENV LANGUAGE='en_US:en' + + +# We make four distinct layers so if there are application changes the library layers can be re-used +COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ +COPY --chown=185 target/quarkus-app/*.jar /deployments/ +COPY --chown=185 target/quarkus-app/app/ /deployments/app/ +COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ + +EXPOSE 8080 +USER 185 +ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" + +ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] + diff --git a/aws-sqs-sink/src/main/docker/Dockerfile.legacy-jar b/aws-sqs-sink/src/main/docker/Dockerfile.legacy-jar new file mode 100644 index 0000000..3dc54e2 --- /dev/null +++ b/aws-sqs-sink/src/main/docker/Dockerfile.legacy-jar @@ -0,0 +1,110 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF 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. +# + +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package -Dquarkus.package.type=legacy-jar +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/code-with-quarkus-legacy-jar . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-legacy-jar +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005. +# Additionally you will have to set -e JAVA_DEBUG=true and -e JAVA_DEBUG_PORT=*:5005 +# when running the container +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-legacy-jar +# +# This image uses the `run-java.sh` script to run the application. +# This scripts computes the command line to execute your Java application, and +# includes memory/GC tuning. +# You can configure the behavior using the following environment properties: +# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") +# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options +# in JAVA_OPTS (example: "-Dsome.property=foo") +# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is +# used to calculate a default maximal heap memory based on a containers restriction. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio +# of the container available memory as set here. The default is `50` which means 50% +# of the available memory is used as an upper boundary. You can skip this mechanism by +# setting this value to `0` in which case no `-Xmx` option is added. +# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This +# is used to calculate a default initial heap memory based on the maximum heap memory. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio +# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` +# is used as the initial heap size. You can skip this mechanism by setting this value +# to `0` in which case no `-Xms` option is added (example: "25") +# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. +# This is used to calculate the maximum value of the initial heap memory. If used in +# a container without any memory constraints for the container then this option has +# no effect. If there is a memory constraint then `-Xms` is limited to the value set +# here. The default is 4096MB which means the calculated value of `-Xms` never will +# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") +# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output +# when things are happening. This option, if set to true, will set +# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). +# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: +# true"). +# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). +# - CONTAINER_CORE_LIMIT: A calculated core limit as described in +# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") +# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). +# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. +# (example: "20") +# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. +# (example: "40") +# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. +# (example: "4") +# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus +# previous GC times. (example: "90") +# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") +# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") +# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should +# contain the necessary JRE command-line options to specify the required GC, which +# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). +# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") +# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") +# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be +# accessed directly. (example: "foo.example.com,bar.example.com") +# +### +FROM registry.access.redhat.com/ubi8/openjdk-17:1.16 + +ENV LANGUAGE='en_US:en' + + +COPY target/lib/* /deployments/lib/ +COPY target/*-runner.jar /deployments/quarkus-run.jar + +EXPOSE 8080 +USER 185 +ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" + +ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ] diff --git a/aws-sqs-sink/src/main/docker/Dockerfile.native b/aws-sqs-sink/src/main/docker/Dockerfile.native new file mode 100644 index 0000000..d5c985f --- /dev/null +++ b/aws-sqs-sink/src/main/docker/Dockerfile.native @@ -0,0 +1,44 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF 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. +# + +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. +# +# Before building the container image run: +# +# ./mvnw package -Dnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native -t quarkus/code-with-quarkus . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus +# +### +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root target/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/aws-sqs-sink/src/main/docker/Dockerfile.native-micro b/aws-sqs-sink/src/main/docker/Dockerfile.native-micro new file mode 100644 index 0000000..ea5c4c9 --- /dev/null +++ b/aws-sqs-sink/src/main/docker/Dockerfile.native-micro @@ -0,0 +1,47 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF 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. +# + +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. +# It uses a micro base image, tuned for Quarkus native executables. +# It reduces the size of the resulting container image. +# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image. +# +# Before building the container image run: +# +# ./mvnw package -Dnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/code-with-quarkus . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus +# +### +FROM quay.io/quarkus/quarkus-micro-image:2.0 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root target/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/aws-sqs-sink/src/main/kubernetes/kubernetes.yml b/aws-sqs-sink/src/main/kubernetes/kubernetes.yml new file mode 100644 index 0000000..7188591 --- /dev/null +++ b/aws-sqs-sink/src/main/kubernetes/kubernetes.yml @@ -0,0 +1,17 @@ +apiVersion: eventing.knative.dev/v1 +kind: Trigger +metadata: + annotations: + eventing.knative.dev/creator: kn-connectors + labels: + eventing.knative.dev/connector: aws-sqs-sink + eventing.knative.dev/broker: default + name: kn-connector-aws-sqs-sink +spec: + broker: default + subscriber: + ref: + apiVersion: v1 + kind: Service + name: kn-connector-aws-sqs-sink + uri: /events diff --git a/aws-sqs-sink/src/main/resources/META-INF/LICENSE.txt b/aws-sqs-sink/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000..6b0b127 --- /dev/null +++ b/aws-sqs-sink/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed 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. + diff --git a/aws-sqs-sink/src/main/resources/META-INF/NOTICE.txt b/aws-sqs-sink/src/main/resources/META-INF/NOTICE.txt new file mode 100644 index 0000000..3bb8201 --- /dev/null +++ b/aws-sqs-sink/src/main/resources/META-INF/NOTICE.txt @@ -0,0 +1,11 @@ + ========================================================================= + == NOTICE file corresponding to the section 4 d of == + == the Apache License, Version 2.0, == + == in this case for the Knative Connector distribution. == + ========================================================================= + + This product includes software developed by + The Knative community (https://knative.dev/). + + Please read the different LICENSE files present in the licenses directory of + this distribution. diff --git a/aws-sqs-sink/src/main/resources/application.properties b/aws-sqs-sink/src/main/resources/application.properties new file mode 100644 index 0000000..7ad07aa --- /dev/null +++ b/aws-sqs-sink/src/main/resources/application.properties @@ -0,0 +1,34 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF 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. +# + +quarkus.camel.openapi.codegen.model-package=org.apache.camel.quarkus + +quarkus.native.resources.includes=camel/kn-connector-sink.yaml +camel.main.routes-include-pattern=camel/kn-connector-sink.yaml + +# Knative Camel component +camel.component.knative.environmentPath=classpath:knative.json + +# Explicitly set event type to empty value to receive all events by default +camel.component.knative.typeId= + +# Kamelet sink properties +# camel.kamelet.aws-sqs-sink.= + +# ConfigMap and secret based configuration +camel.kubernetes-config.mount-path-configmaps=/etc/camel/conf.d/_configmaps/kn-sink-config +camel.kubernetes-config.mount-path-secrets=/etc/camel/conf.d/_secrets/kn-sink-config diff --git a/aws-sqs-sink/src/main/resources/camel/kn-connector-sink.yaml b/aws-sqs-sink/src/main/resources/camel/kn-connector-sink.yaml new file mode 100644 index 0000000..eefb5f0 --- /dev/null +++ b/aws-sqs-sink/src/main/resources/camel/kn-connector-sink.yaml @@ -0,0 +1,34 @@ +# --------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF 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. +# --------------------------------------------------------------------------- + +apiVersion: camel.apache.org/v1 +kind: Pipe +metadata: + name: kn-connector-aws-sqs-sink +spec: + source: + ref: + kind: Broker + apiVersion: eventing.knative.dev/v1 + name: default + properties: + type: "" + sink: + ref: + kind: Kamelet + apiVersion: camel.apache.org/v1 + name: aws-sqs-sink diff --git a/aws-sqs-sink/src/main/resources/knative.json b/aws-sqs-sink/src/main/resources/knative.json new file mode 100644 index 0000000..c5d3081 --- /dev/null +++ b/aws-sqs-sink/src/main/resources/knative.json @@ -0,0 +1,14 @@ +{ + "resources": [ + { + "name": "default", + "type": "event", + "endpointKind": "source", + "path": "/events", + "objectApiVersion": "eventing.knative.dev/v1", + "objectKind": "Broker", + "objectName": "default", + "reply": false + } + ] +} diff --git a/pom.xml b/pom.xml index 130abdb..f75e77c 100644 --- a/pom.xml +++ b/pom.xml @@ -45,6 +45,7 @@ aws-sqs-source aws-ddb-streams-source aws-s3-sink + aws-sqs-sink log-sink