From 7d435cb0fcdc050397fafb02370d967b1ac69a6b Mon Sep 17 00:00:00 2001 From: wanjunlei Date: Tue, 31 Jan 2023 16:16:32 +0800 Subject: [PATCH] update function API version to v1beta2 Signed-off-by: wanjunlei --- apps/buildah/go/sample-go-app.yaml | 32 ++--- apps/buildah/java/sample-java-app.yaml | 37 +++--- .../java/sample-java-app-buildpacks.yaml | 30 +++-- apps/kaniko/function-kaniko.yaml | 32 +++-- apps/ko/function-ko.yaml | 32 +++-- .../cron-input-kafka-output.go | 3 +- .../cron-input-kafka-output.yaml | 94 +++++++------- .../async/bindings/cron-input/cron-input.yaml | 47 +++---- .../bindings/kafka-input/kafka-input.yaml | 101 ++++++++------- .../cron-input-kafka-output.yaml | 86 +++++++------ .../async/java/kafka-input/kafka-input.yaml | 107 ++++++++-------- .../java/pubsub/function-subscriber.yaml | 105 +++++++-------- .../logs-handler-function.yaml | 121 ++++++++++-------- .../async/mqtt-io-node/async-bindings.yaml | 65 ++++------ .../async/mqtt-io-node/async-pubsub.yaml | 50 ++++---- .../subscriber/function-subscriber.yaml | 94 +++++++------- functions/knative/greeting-node/greeting.yaml | 10 +- .../knative/hello-world-dotnet/README.md | 7 +- .../hello-world-go/function-sample.yaml | 7 +- .../commonjs/function-sample.yaml | 7 +- .../hello-world-node/esm/function-sample.yaml | 6 +- .../knative/hello-world-python/README.md | 6 +- .../java/cloudevent/function-sample.yaml | 8 +- .../java/hello-world/function-sample.yaml | 7 +- .../with-output-binding/function-front.yaml | 25 ++-- .../logs-handler-function.yaml | 8 +- .../function-sample.yaml | 7 +- .../function-sample.yaml | 7 +- .../http-server/wasmedge-http-server.yaml | 21 +-- .../http-trigger.yaml | 15 +-- .../with-output-binding/function-front.yaml | 30 ++--- functions/tracing/README.md | 24 +++- 32 files changed, 649 insertions(+), 582 deletions(-) diff --git a/apps/buildah/go/sample-go-app.yaml b/apps/buildah/go/sample-go-app.yaml index 6652727..26a6610 100644 --- a/apps/buildah/go/sample-go-app.yaml +++ b/apps/buildah/go/sample-go-app.yaml @@ -1,27 +1,29 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: sample-go-app + namespace: default spec: - version: "v1.0.0" - image: "openfunctiondev/sample-go-app:v1" - imageCredentials: - name: push-secret - #port: 8080 # default to 8080 build: builder: openfunction/buildah:v1.23.1 - srcRepo: - url: "https://github.com/OpenFunction/samples.git" - sourceSubPath: "apps/buildah/go" - revision: "main" shipwright: strategy: - name: buildah kind: ClusterBuildStrategy + name: buildah + srcRepo: + revision: main + sourceSubPath: apps/buildah/go + url: https://github.com/OpenFunction/samples.git + image: openfunctiondev/sample-go-app:v1 + imageCredentials: + name: push-secret serving: - runtime: knative template: containers: - - name: function - imagePullPolicy: IfNotPresent - + - imagePullPolicy: IfNotPresent + name: function + triggers: + http: + port: 8080 + version: v1.0.0 + workloadRuntime: OCIContainer diff --git a/apps/buildah/java/sample-java-app.yaml b/apps/buildah/java/sample-java-app.yaml index 1e9e5c4..7858ee8 100644 --- a/apps/buildah/java/sample-java-app.yaml +++ b/apps/buildah/java/sample-java-app.yaml @@ -1,27 +1,34 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: sample-java-app + namespace: default spec: - version: "v1.0.0" - image: "openfunctiondev/sample-java-app:v1" - imageCredentials: - name: push-secret - #port: 8080 # default to 8080 build: builder: openfunction/buildah:v1.23.1 - srcRepo: - url: "https://github.com/OpenFunction/samples.git" - sourceSubPath: "apps/buildah/java" - revision: "main" shipwright: strategy: - name: buildah kind: ClusterBuildStrategy + name: buildah + srcRepo: + revision: main + sourceSubPath: apps/buildah/java + url: https://github.com/OpenFunction/samples.git + image: openfunctiondev/sample-java-app:v1 + imageCredentials: + name: push-secret serving: - runtime: knative template: containers: - - name: function - imagePullPolicy: IfNotPresent - + - imagePullPolicy: IfNotPresent + name: function + resources: {} + triggers: + http: + port: 8080 + route: + gatewayRef: + name: openfunction + namespace: openfunction + version: v1.0.0 + workloadRuntime: OCIContainer diff --git a/apps/buildpacks/java/sample-java-app-buildpacks.yaml b/apps/buildpacks/java/sample-java-app-buildpacks.yaml index d1fb7fc..b815a4a 100644 --- a/apps/buildpacks/java/sample-java-app-buildpacks.yaml +++ b/apps/buildpacks/java/sample-java-app-buildpacks.yaml @@ -1,22 +1,26 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: sample-java-app-buildpacks + namespace: default spec: - version: "v1.0.0" - image: "openfunction/sample-java-app-buildpacks:v1" - imageCredentials: - name: push-secret - port: 8080 # default to 8080 build: - builder: "cnbs/sample-builder:alpine" + builder: cnbs/sample-builder:alpine srcRepo: - url: "https://github.com/buildpacks/samples.git" - sourceSubPath: "apps/java-maven" - revision: "main" + revision: main + sourceSubPath: apps/java-maven + url: https://github.com/buildpacks/samples.git + image: openfunction/sample-java-app-buildpacks:v1 + imageCredentials: + name: push-secret serving: - runtime: "knative" # default to knative template: containers: - - name: function - imagePullPolicy: IfNotPresent + - imagePullPolicy: IfNotPresent + name: function + resources: {} + triggers: + http: + port: 8080 + version: v1.0.0 + workloadRuntime: OCIContainer diff --git a/apps/kaniko/function-kaniko.yaml b/apps/kaniko/function-kaniko.yaml index c5babc2..bf71d37 100644 --- a/apps/kaniko/function-kaniko.yaml +++ b/apps/kaniko/function-kaniko.yaml @@ -1,26 +1,30 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: function-kaniko + namespace: default spec: - version: "v1.0.0" - image: "openfunctiondev/sample-kankio-go:latest" - imageCredentials: - name: push-secret - #port: 8080 # default to 8080 build: builder: openfunction/kaniko-executor:v1.7.0 - srcRepo: - url: "https://github.com/OpenFunction/samples.git" - sourceSubPath: "apps/with-dockerfile" - revision: "main" shipwright: strategy: - name: kaniko kind: ClusterBuildStrategy + name: kaniko + srcRepo: + revision: main + sourceSubPath: apps/buildah/go + url: https://github.com/OpenFunction/samples.git + image: openfunctiondev/sample-kankio-go:latest + imageCredentials: + name: push-secret serving: - runtime: knative template: containers: - - name: function - imagePullPolicy: Always + - imagePullPolicy: Always + name: function + resources: {} + triggers: + http: + port: 8080 + version: v1.0.0 + workloadRuntime: OCIContainer diff --git a/apps/ko/function-ko.yaml b/apps/ko/function-ko.yaml index fd2151d..8e05179 100644 --- a/apps/ko/function-ko.yaml +++ b/apps/ko/function-ko.yaml @@ -1,26 +1,30 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: function-ko + namespace: default spec: - version: "v1.0.0" - image: "openfunctiondev/sample-ko:latest" - imageCredentials: - name: push-secret - #port: 8080 # default to 8080 build: builder: golang:1.17 - srcRepo: - url: "https://github.com/OpenFunction/samples.git" - sourceSubPath: "apps/with-dockerfile" - revision: "main" shipwright: strategy: - name: ko kind: ClusterBuildStrategy + name: ko + srcRepo: + revision: main + sourceSubPath: apps/buildah/go + url: https://github.com/OpenFunction/samples.git + image: openfunctiondev/sample-ko:latest + imageCredentials: + name: push-secret serving: - runtime: knative template: containers: - - name: function - imagePullPolicy: Always + - imagePullPolicy: Always + name: function + resources: {} + triggers: + http: + port: 8080 + version: v1.0.0 + workloadRuntime: OCIContainer diff --git a/functions/async/bindings/cron-input-kafka-output/cron-input-kafka-output.go b/functions/async/bindings/cron-input-kafka-output/cron-input-kafka-output.go index 92cd7bd..c200f01 100644 --- a/functions/async/bindings/cron-input-kafka-output/cron-input-kafka-output.go +++ b/functions/async/bindings/cron-input-kafka-output/cron-input-kafka-output.go @@ -17,10 +17,11 @@ func HandleCronInput(ctx ofctx.Context, in []byte) (ofctx.Out, error) { greeting, _ = json.Marshal(map[string]string{"message": "Hello"}) } - _, err := ctx.Send("sample", greeting) + _, err := ctx.Send("kafka-server", greeting) if err != nil { log.Printf("Error: %v\n", err) return ctx.ReturnOnInternalError(), err } + return ctx.ReturnOnSuccess(), nil } diff --git a/functions/async/bindings/cron-input-kafka-output/cron-input-kafka-output.yaml b/functions/async/bindings/cron-input-kafka-output/cron-input-kafka-output.yaml index 7947581..52b18ed 100644 --- a/functions/async/bindings/cron-input-kafka-output/cron-input-kafka-output.yaml +++ b/functions/async/bindings/cron-input-kafka-output/cron-input-kafka-output.yaml @@ -1,62 +1,66 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: cron-input-kafka-output - annotations: - plugins: | - pre: - - plugin-custom - - plugin-example - post: - - plugin-custom - - plugin-example + namespace: default spec: - version: "v2.0.0" - image: openfunctiondev/cron-input-kafka-output:v1 - imageCredentials: - name: push-secret build: builder: openfunction/builder-go:latest env: - FUNC_NAME: "HandleCronInput" FUNC_CLEAR_SOURCE: "true" -# # Use FUNC_GOPROXY to set the goproxy if failed to fetch go modules -# FUNC_GOPROXY: "https://goproxy.cn" + FUNC_NAME: HandleCronInput + # # Use FUNC_GOPROXY to set the goproxy if failed to fetch go modules + # FUNC_GOPROXY: "https://goproxy.cn" srcRepo: - url: "https://github.com/OpenFunction/samples.git" - sourceSubPath: "functions/async/bindings/cron-input-kafka-output" - revision: "main" + revision: main + sourceSubPath: functions/async/bindings/cron-input-kafka-output + url: https://github.com/OpenFunction/samples.git + image: openfunctiondev/cron-input-kafka-output:v1 + imageCredentials: + name: push-secret serving: - template: - containers: - - name: function # DO NOT change this - imagePullPolicy: IfNotPresent - runtime: "async" - inputs: - - name: cron - component: cron - outputs: - - name: sample - component: kafka-server - operation: "create" bindings: cron: + metadata: + - name: schedule + value: '@every 2s' type: bindings.cron version: v1 - metadata: - - name: schedule - value: "@every 2s" kafka-server: + ignoreErrors: false + initTimeout: "" + metadata: + - name: brokers + value: kafka-server-kafka-brokers:9092 + - name: topics + value: sample-topic + - name: consumerGroup + value: bindings-with-output + - name: publishTopic + value: sample-topic + - name: authRequired + value: "false" type: bindings.kafka version: v1 - metadata: - - name: brokers - value: "kafka-server-kafka-brokers:9092" - - name: topics - value: "sample-topic" - - name: consumerGroup - value: "bindings-with-output" - - name: publishTopic - value: "sample-topic" - - name: authRequired - value: "false" + hooks: + post: + - plugin-custom + - plugin-example + pre: + - plugin-example + - plugin-custom + outputs: + - dapr: + name: kafka-server + operation: create + type: bindings.kafka + template: + containers: + - imagePullPolicy: IfNotPresent + name: function + triggers: + dapr: + - name: cron + type: bindings.cron + version: v2.0.0 + workloadRuntime: OCIContainer diff --git a/functions/async/bindings/cron-input/cron-input.yaml b/functions/async/bindings/cron-input/cron-input.yaml index ef0388b..7947bae 100644 --- a/functions/async/bindings/cron-input/cron-input.yaml +++ b/functions/async/bindings/cron-input/cron-input.yaml @@ -1,36 +1,39 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: cron-input + namespace: default spec: - version: "v2.0.0" - image: openfunctiondev/cron-input:v1 - imageCredentials: - name: push-secret build: builder: openfunction/builder-go:latest env: - FUNC_NAME: "HandleCronInput" FUNC_CLEAR_SOURCE: "true" -# # Use FUNC_GOPROXY to set the goproxy if failed to fetch go modules -# FUNC_GOPROXY: "https://goproxy.cn" + FUNC_NAME: HandleCronInput + # # Use FUNC_GOPROXY to set the goproxy if failed to fetch go modules + # FUNC_GOPROXY: "https://goproxy.cn" srcRepo: - url: "https://github.com/OpenFunction/samples.git" - sourceSubPath: "functions/async/bindings/cron-input" - revision: "main" + revision: main + sourceSubPath: functions/async/bindings/cron-input + url: https://github.com/OpenFunction/samples.git + image: openfunctiondev/cron-input:v1 + imageCredentials: + name: push-secret serving: - template: - containers: - - name: function # DO NOT change this - imagePullPolicy: IfNotPresent - runtime: "async" - inputs: - - name: input - component: cron bindings: cron: + metadata: + - name: schedule + value: '@every 2s' type: bindings.cron version: v1 - metadata: - - name: schedule - value: "@every 2s" + template: + containers: + - imagePullPolicy: IfNotPresent + name: function + resources: { } + triggers: + dapr: + - name: cron + type: bindings.cron + version: v2.0.0 + workloadRuntime: OCIContainer diff --git a/functions/async/bindings/kafka-input/kafka-input.yaml b/functions/async/bindings/kafka-input/kafka-input.yaml index 0d552cb..9968a5a 100644 --- a/functions/async/bindings/kafka-input/kafka-input.yaml +++ b/functions/async/bindings/kafka-input/kafka-input.yaml @@ -1,71 +1,74 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: kafka-input + namespace: default spec: - version: "v1.0.0" - image: openfunctiondev/kafka-input:v1 - imageCredentials: - name: push-secret build: builder: openfunction/builder-go:latest env: - FUNC_NAME: "HandleKafkaInput" FUNC_CLEAR_SOURCE: "true" -# # Use FUNC_GOPROXY to set the goproxy if failed to fetch go modules -# FUNC_GOPROXY: "https://goproxy.cn" + FUNC_NAME: HandleKafkaInput + # # Use FUNC_GOPROXY to set the goproxy if failed to fetch go modules + # FUNC_GOPROXY: "https://goproxy.cn" srcRepo: - url: "https://github.com/OpenFunction/samples.git" - sourceSubPath: "functions/async/bindings/kafka-input" - revision: "main" + revision: main + sourceSubPath: functions/async/bindings/kafka-input + url: https://github.com/OpenFunction/samples.git + image: openfunctiondev/kafka-input:v1 + imageCredentials: + name: push-secret serving: - runtime: async + bindings: + target-topic: + ignoreErrors: false + initTimeout: "" + metadata: + - name: brokers + value: kafka-server-kafka-brokers:9092 + - name: topics + value: sample-topic + - name: consumerGroup + value: kafka-input + - name: publishTopic + value: sample-topic + - name: authRequired + value: "false" + type: bindings.kafka + version: v1 scaleOptions: - minReplicas: 0 - maxReplicas: 10 keda: scaledObject: - pollingInterval: 15 - minReplicaCount: 0 - maxReplicaCount: 10 - cooldownPeriod: 60 advanced: horizontalPodAutoscalerConfig: behavior: scaleDown: - stabilizationWindowSeconds: 45 policies: - - type: Percent - value: 50 - periodSeconds: 15 + - periodSeconds: 15 + type: Percent + value: 50 + stabilizationWindowSeconds: 45 scaleUp: stabilizationWindowSeconds: 0 - triggers: - - type: kafka - metadata: - topic: sample-topic - bootstrapServers: kafka-server-kafka-brokers.default.svc:9092 - consumerGroup: kafka-input - lagThreshold: "20" - inputs: - - name: greeting - component: target-topic - bindings: - target-topic: - type: bindings.kafka - version: v1 - metadata: - - name: brokers - value: "kafka-server-kafka-brokers:9092" - - name: topics - value: "sample-topic" - - name: consumerGroup - value: "kafka-input" - - name: publishTopic - value: "sample-topic" - - name: authRequired - value: "false" + cooldownPeriod: 60 + pollingInterval: 15 + triggers: + - metadata: + bootstrapServers: kafka-server-kafka-brokers.default.svc:9092 + consumerGroup: kafka-input + lagThreshold: "20" + topic: sample-topic + type: kafka + maxReplicas: 10 + minReplicas: 0 template: containers: - - name: function # DO NOT change this - imagePullPolicy: IfNotPresent + - imagePullPolicy: IfNotPresent + name: function + triggers: + dapr: + - name: target-topic + type: bindings.kafka + workloadType: Deployment + version: v1.0.0 + workloadRuntime: OCIContainer diff --git a/functions/async/java/cron-input-kafka-output/cron-input-kafka-output.yaml b/functions/async/java/cron-input-kafka-output/cron-input-kafka-output.yaml index 02afe4d..d9c3da0 100644 --- a/functions/async/java/cron-input-kafka-output/cron-input-kafka-output.yaml +++ b/functions/async/java/cron-input-kafka-output/cron-input-kafka-output.yaml @@ -1,58 +1,62 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: cron-input-kafka-output-java - annotations: - plugins: | - pre: - - dev.openfunction.samples.plugins.ExamplePlugin - post: - - dev.openfunction.samples.plugins.ExamplePlugin + namespace: default spec: - version: "v2.0.0" - image: openfunctiondev/cron-input-kafka-output-java:v1 - imageCredentials: - name: push-secret build: builder: openfunction/builder-java:v2-18 env: - FUNC_NAME: "dev.openfunction.samples.OpenFunctionImpl" FUNC_CLEAR_SOURCE: "true" + FUNC_NAME: dev.openfunction.samples.OpenFunctionImpl srcRepo: - url: "https://github.com/OpenFunction/samples.git" - sourceSubPath: "functions/knative/java" - revision: "main" + revision: main + sourceSubPath: functions/knative/java + url: https://github.com/OpenFunction/samples.git + image: openfunctiondev/cron-input-kafka-output-java:v1 + imageCredentials: + name: push-secret serving: - template: - containers: - - name: function # DO NOT change this - imagePullPolicy: IfNotPresent - runtime: "async" - inputs: - - name: cron - component: cron - outputs: - - name: sample - component: kafka-server - operation: "create" bindings: cron: + metadata: + - name: schedule + value: '@every 2s' type: bindings.cron version: v1 - metadata: - - name: schedule - value: "@every 2s" kafka-server: + ignoreErrors: false + initTimeout: "" + metadata: + - name: brokers + value: kafka-server-kafka-brokers:9092 + - name: topics + value: sample-topic + - name: consumerGroup + value: bindings-with-output + - name: publishTopic + value: sample-topic + - name: authRequired + value: "false" type: bindings.kafka version: v1 - metadata: - - name: brokers - value: "kafka-server-kafka-brokers:9092" - - name: topics - value: "sample-topic" - - name: consumerGroup - value: "bindings-with-output" - - name: publishTopic - value: "sample-topic" - - name: authRequired - value: "false" + hooks: + post: + - dev.openfunction.samples.plugins.ExamplePlugin + pre: + - dev.openfunction.samples.plugins.ExamplePlugin + outputs: + - dapr: + name: kafka-server + operation: create + type: bindings.kafka + template: + containers: + - imagePullPolicy: IfNotPresent + name: function + triggers: + dapr: + - name: cron + type: bindings.cron + version: v2.0.0 + workloadRuntime: OCIContainer diff --git a/functions/async/java/kafka-input/kafka-input.yaml b/functions/async/java/kafka-input/kafka-input.yaml index f9012bf..abb9bb9 100644 --- a/functions/async/java/kafka-input/kafka-input.yaml +++ b/functions/async/java/kafka-input/kafka-input.yaml @@ -1,75 +1,78 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: kafka-input-java - annotations: - plugins: | - pre: - - dev.openfunction.samples.plugins.ExamplePlugin - post: - - dev.openfunction.samples.plugins.ExamplePlugin + namespace: default spec: - version: "v1.0.0" - image: openfunctiondev/kafka-input-java:v1 - imageCredentials: - name: push-secret build: builder: openfunction/builder-java:v2-18 env: - FUNC_NAME: "dev.openfunction.samples.OpenFunctionImpl" FUNC_CLEAR_SOURCE: "true" + FUNC_NAME: dev.openfunction.samples.OpenFunctionImpl srcRepo: - url: "https://github.com/OpenFunction/samples.git" - sourceSubPath: "functions/knative/java" - revision: "main" + revision: main + sourceSubPath: functions/knative/java + url: https://github.com/OpenFunction/samples.git + image: openfunctiondev/kafka-input-java:v1 + imageCredentials: + name: push-secret serving: - runtime: async + bindings: + target-topic: + ignoreErrors: false + initTimeout: "" + metadata: + - name: brokers + value: kafka-server-kafka-brokers:9092 + - name: topics + value: sample-topic + - name: consumerGroup + value: kafka-input + - name: publishTopic + value: sample-topic + - name: authRequired + value: "false" + type: bindings.kafka + version: v1 + hooks: + policy: Override + post: + - dev.openfunction.samples.plugins.ExamplePlugin + pre: + - dev.openfunction.samples.plugins.ExamplePlugin scaleOptions: - minReplicas: 0 - maxReplicas: 10 keda: scaledObject: - pollingInterval: 15 - minReplicaCount: 0 - maxReplicaCount: 10 - cooldownPeriod: 60 advanced: horizontalPodAutoscalerConfig: behavior: scaleDown: - stabilizationWindowSeconds: 45 policies: - - type: Percent + - periodSeconds: 15 + type: Percent value: 50 - periodSeconds: 15 + stabilizationWindowSeconds: 45 scaleUp: stabilizationWindowSeconds: 0 - triggers: - - type: kafka - metadata: - topic: sample-topic - bootstrapServers: kafka-server-kafka-brokers.default.svc:9092 - consumerGroup: kafka-input - lagThreshold: "20" - inputs: - - name: greeting - component: target-topic - bindings: - target-topic: - type: bindings.kafka - version: v1 - metadata: - - name: brokers - value: "kafka-server-kafka-brokers:9092" - - name: topics - value: "sample-topic" - - name: consumerGroup - value: "kafka-input" - - name: publishTopic - value: "sample-topic" - - name: authRequired - value: "false" + cooldownPeriod: 60 + pollingInterval: 15 + triggers: + - metadata: + bootstrapServers: kafka-server-kafka-brokers.default.svc:9092 + consumerGroup: kafka-input + lagThreshold: "20" + topic: sample-topic + type: kafka + maxReplicas: 10 + minReplicas: 0 template: containers: - - name: function # DO NOT change this - imagePullPolicy: IfNotPresent + - imagePullPolicy: IfNotPresent + name: function + triggers: + dapr: + - name: target-topic + type: bindings.kafka + workloadType: Deployment + version: v1.0.0 + workloadRuntime: OCIContainer diff --git a/functions/async/java/pubsub/function-subscriber.yaml b/functions/async/java/pubsub/function-subscriber.yaml index feaec5d..c41f746 100644 --- a/functions/async/java/pubsub/function-subscriber.yaml +++ b/functions/async/java/pubsub/function-subscriber.yaml @@ -1,74 +1,75 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: autoscaling-subscriber-java - annotations: - plugins: | - pre: - - dev.openfunction.samples.plugins.ExamplePlugin - post: - - dev.openfunction.samples.plugins.ExamplePlugin + namespace: default spec: - version: "v2.0.0" - image: openfunctiondev/autoscaling-subscriber-java:v1 - imageCredentials: - name: push-secret build: builder: openfunction/builder-java:v2-18 env: - FUNC_NAME: "dev.openfunction.samples.OpenFunctionImpl" FUNC_CLEAR_SOURCE: "true" - # Use FUNC_GOPROXY to set the goproxy - # FUNC_GOPROXY: "https://goproxy.cn" + FUNC_NAME: dev.openfunction.samples.OpenFunctionImpl srcRepo: - url: "https://github.com/OpenFunction/samples.git" - sourceSubPath: "functions/knative/java" - revision: "main" + revision: main + sourceSubPath: functions/knative/java + url: https://github.com/OpenFunction/samples.git + image: openfunctiondev/autoscaling-subscriber-java:v1 + imageCredentials: + name: push-secret serving: - runtime: "async" + hooks: + policy: Override + post: + - dev.openfunction.samples.plugins.ExamplePlugin + pre: + - dev.openfunction.samples.plugins.ExamplePlugin + pubsub: + kafka-server: + metadata: + - name: brokers + value: kafka-server-kafka-brokers:9092 + - name: authRequired + value: "false" + - name: allowedTopics + value: sample-topic + - name: consumerID + value: autoscaling-subscriber + type: pubsub.kafka + version: v1 scaleOptions: keda: scaledObject: - pollingInterval: 15 - minReplicaCount: 0 - maxReplicaCount: 10 - cooldownPeriod: 60 advanced: horizontalPodAutoscalerConfig: behavior: scaleDown: - stabilizationWindowSeconds: 45 policies: - - type: Percent - value: 50 - periodSeconds: 15 + - periodSeconds: 15 + type: Percent + value: 50 + stabilizationWindowSeconds: 45 scaleUp: stabilizationWindowSeconds: 0 - triggers: - - type: kafka - metadata: - topic: "sample-topic" - bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092 - consumerGroup: autoscaling-subscriber - lagThreshold: "20" + cooldownPeriod: 60 + pollingInterval: 15 + triggers: + - metadata: + bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092 + consumerGroup: autoscaling-subscriber + lagThreshold: "20" + topic: sample-topic + type: kafka + maxReplicas: 10 + minReplicas: 0 template: containers: - - name: function # DO NOT change this - imagePullPolicy: IfNotPresent - inputs: - - name: producer - component: kafka-server - topic: "sample-topic" - pubsub: - kafka-server: - type: pubsub.kafka - version: v1 - metadata: - - name: brokers - value: "kafka-server-kafka-brokers:9092" - - name: authRequired - value: "false" - - name: allowedTopics - value: "sample-topic" - - name: consumerID - value: "autoscaling-subscriber" + - imagePullPolicy: IfNotPresent + name: function + triggers: + dapr: + - name: kafka-server + topic: sample-topic + type: pubsub.kafka + workloadType: Deployment + version: v2.0.0 + workloadRuntime: OCIContainer diff --git a/functions/async/logs-handler-function/logs-handler-function.yaml b/functions/async/logs-handler-function/logs-handler-function.yaml index 162f6f8..e55b600 100644 --- a/functions/async/logs-handler-function/logs-handler-function.yaml +++ b/functions/async/logs-handler-function/logs-handler-function.yaml @@ -1,79 +1,88 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: + annotations: + kubectl.kubernetes.io/last-applied-configuration: | + {"apiVersion":"core.openfunction.io/v1beta1","kind":"Function","metadata":{"annotations":{},"name":"logs-async-handler","namespace":"default"},"spec":{"build":{"builder":"openfunction/builder-go:latest","env":{"FUNC_CLEAR_SOURCE":"true","FUNC_NAME":"LogsHandler"},"srcRepo":{"revision":"main","sourceSubPath":"functions/async/logs-handler-function/","url":"https://github.com/OpenFunction/samples.git"}},"image":"openfunctiondev/logs-async-handler:v1","imageCredentials":{"name":"push-secret"},"serving":{"bindings":{"kafka-receiver":{"metadata":[{"name":"brokers","value":"kafka-server-kafka-brokers:9092"},{"name":"authRequired","value":"false"},{"name":"publishTopic","value":"logs"},{"name":"topics","value":"logs"},{"name":"consumerGroup","value":"logs-handler"}],"type":"bindings.kafka","version":"v1"},"notification-manager":{"metadata":[{"name":"url","value":"http://notification-manager-svc.kubesphere-monitoring-system.svc.cluster.local:19093/api/v2/alerts"}],"type":"bindings.http","version":"v1"}},"inputs":[{"component":"kafka-receiver","name":"kafka"}],"outputs":[{"component":"notification-manager","name":"notify","operation":"post"}],"runtime":"async","scaleOptions":{"keda":{"scaledObject":{"advanced":{"horizontalPodAutoscalerConfig":{"behavior":{"scaleDown":{"policies":[{"periodSeconds":15,"type":"Percent","value":50}],"stabilizationWindowSeconds":45},"scaleUp":{"stabilizationWindowSeconds":0}}}},"cooldownPeriod":60,"maxReplicaCount":10,"minReplicaCount":0,"pollingInterval":15}}},"template":{"containers":[{"imagePullPolicy":"IfNotPresent","name":"function"}]},"triggers":[{"metadata":{"bootstrapServers":"kafka-server-kafka-brokers.default.svc.cluster.local:9092","consumerGroup":"logs-handler","lagThreshold":"20","topic":"logs"},"type":"kafka"}]},"version":"v2.0.0"}} + creationTimestamp: "2023-05-19T02:19:38Z" + generation: 1 name: logs-async-handler + namespace: default + resourceVersion: "1403299" + uid: 54152eff-b301-4bf1-889c-60772eabb2f9 spec: - version: "v2.0.0" - image: openfunctiondev/logs-async-handler:v1 - imageCredentials: - name: push-secret build: builder: openfunction/builder-go:latest env: - FUNC_NAME: "LogsHandler" FUNC_CLEAR_SOURCE: "true" -# # Use FUNC_GOPROXY to set the goproxy if failed to fetch go modules -# FUNC_GOPROXY: "https://goproxy.cn" + FUNC_NAME: LogsHandler srcRepo: - url: "https://github.com/OpenFunction/samples.git" - sourceSubPath: "functions/async/logs-handler-function/" - revision: "main" + revision: main + sourceSubPath: functions/async/logs-handler-function/ + url: https://github.com/OpenFunction/samples.git + image: openfunctiondev/logs-async-handler:v1 + imageCredentials: + name: push-secret serving: - runtime: "async" - scaleOptions: - keda: - scaledObject: - pollingInterval: 15 - minReplicaCount: 0 - maxReplicaCount: 10 - cooldownPeriod: 60 - advanced: - horizontalPodAutoscalerConfig: - behavior: - scaleDown: - stabilizationWindowSeconds: 45 - policies: - - type: Percent - value: 50 - periodSeconds: 15 - scaleUp: - stabilizationWindowSeconds: 0 - triggers: - - type: kafka - metadata: - topic: logs - bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092 - consumerGroup: logs-handler - lagThreshold: "20" - template: - containers: - - name: function # DO NOT change this - imagePullPolicy: IfNotPresent - inputs: - - name: kafka - component: kafka-receiver - outputs: - - name: notify - component: notification-manager - operation: "post" bindings: kafka-receiver: - type: bindings.kafka - version: v1 metadata: - name: brokers - value: "kafka-server-kafka-brokers:9092" + value: kafka-server-kafka-brokers:9092 - name: authRequired value: "false" - name: publishTopic - value: "logs" + value: logs - name: topics - value: "logs" + value: logs - name: consumerGroup - value: "logs-handler" - notification-manager: - type: bindings.http + value: logs-handler + type: bindings.kafka version: v1 + notification-manager: metadata: - name: url value: http://notification-manager-svc.kubesphere-monitoring-system.svc.cluster.local:19093/api/v2/alerts + type: bindings.http + version: v1 + outputs: + - dapr: + name: notification-manager + operation: post + type: bindings.http + scaleOptions: + keda: + scaledObject: + advanced: + horizontalPodAutoscalerConfig: + behavior: + scaleDown: + policies: + - periodSeconds: 15 + type: Percent + value: 50 + stabilizationWindowSeconds: 45 + scaleUp: + stabilizationWindowSeconds: 0 + cooldownPeriod: 60 + pollingInterval: 15 + triggers: + - metadata: + bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092 + consumerGroup: logs-handler + lagThreshold: "20" + topic: logs + type: kafka + maxReplicas: 10 + minReplicas: 0 + template: + containers: + - imagePullPolicy: IfNotPresent + name: function + triggers: + dapr: + - name: kafka-receiver + type: bindings.kafka + workloadType: Deployment + version: v2.0.0 + workloadRuntime: OCIContainer diff --git a/functions/async/mqtt-io-node/async-bindings.yaml b/functions/async/mqtt-io-node/async-bindings.yaml index 017e42e..4e70e85 100644 --- a/functions/async/mqtt-io-node/async-bindings.yaml +++ b/functions/async/mqtt-io-node/async-bindings.yaml @@ -1,53 +1,17 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: sample-node-async-bindings + namespace: default spec: - version: v2.0.0 image: your-docker-registry/image:v1 - # imageCredentials: - # name: your-docker-registry-secret - # build: - # builder: openfunction/builder-node:v2-16.13 - # env: - # FUNC_NAME: tryKnative - # srcRepo: - # url: https://github.com/OpenFunction/samples.git - # sourceSubPath: functions/async/mqtt-io-node - # revision: main - # app port default to "8080" - # port: 8080 serving: - # default to knative - runtime: async annotations: - # Dapr annotations: https://docs.dapr.io/reference/arguments-annotations-overview/ - # default to "grpc" dapr.io/app-protocol: http - # default to "info" + dapr.io/log-as-json: "false" dapr.io/log-level: debug - # default to "true" - dapr.io/log-as-json: 'false' - template: - containers: - - name: function # DO NOT change this - imagePullPolicy: IfNotPresent - params: - # default to FUNC_NAME value - FUNCTION_TARGET: tryAsync - DEBUG: common:*,ofn:* - inputs: - - name: mqtt-input - component: mqtt-in - outputs: - - name: mqtt-output - component: mqtt-out - operation: create bindings: - # Dapr MQTT Binding: https://docs.dapr.io/reference/components-reference/supported-bindings/mqtt/ mqtt-in: - type: bindings.mqtt - version: v1 metadata: - name: consumerID value: '{uuid}' @@ -55,9 +19,9 @@ spec: value: tcp://admin:public@emqx:1883 - name: topic value: in - mqtt-out: type: bindings.mqtt version: v1 + mqtt-out: metadata: - name: consumerID value: '{uuid}' @@ -65,3 +29,24 @@ spec: value: tcp://admin:public@emqx:1883 - name: topic value: out + type: bindings.mqtt + version: v1 + outputs: + - dapr: + name: mqtt-out + operation: create + type: bindings.mqtt + params: + DEBUG: common:*,ofn:* + FUNCTION_TARGET: tryAsync + template: + containers: + - imagePullPolicy: IfNotPresent + name: function + triggers: + dapr: + - name: mqtt-in + type: bindings.mqtt + version: v2.0.0 + workloadRuntime: OCIContainer + diff --git a/functions/async/mqtt-io-node/async-pubsub.yaml b/functions/async/mqtt-io-node/async-pubsub.yaml index 3bbd5b9..63f5e81 100644 --- a/functions/async/mqtt-io-node/async-pubsub.yaml +++ b/functions/async/mqtt-io-node/async-pubsub.yaml @@ -1,9 +1,9 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: sample-node-async-pubsub + namespace: default spec: - version: v2.0.0 image: your-docker-registry/image:v1 # imageCredentials: # name: your-docker-registry-secret @@ -15,40 +15,21 @@ spec: # url: https://github.com/OpenFunction/samples.git # sourceSubPath: functions/async/mqtt-io-node # revision: main - # app port default to "8080" - # port: 8080 serving: - # default to knative - runtime: async annotations: - # Dapr annotations: https://docs.dapr.io/reference/arguments-annotations-overview/ - # default to "grpc" dapr.io/app-protocol: http - # default to "info" + dapr.io/log-as-json: "false" dapr.io/log-level: debug - # default to "true" - dapr.io/log-as-json: 'false' - template: - containers: - - name: function # DO NOT change this - imagePullPolicy: IfNotPresent + outputs: + - dapr: + name: mqtt-pubsub + topic: pub + type: pubsub.mqtt params: - # default to FUNC_NAME value - FUNCTION_TARGET: tryAsync DEBUG: common:*,ofn:* - inputs: - - name: mqtt-sub - component: mqtt-pubsub - topic: sub - outputs: - - name: mqtt-pub - component: mqtt-pubsub - topic: pub + FUNCTION_TARGET: tryAsync pubsub: - # Dapr MQTT PubSub: https://docs.dapr.io/reference/components-reference/supported-pubsub/setup-mqtt/ mqtt-pubsub: - type: pubsub.mqtt - version: v1 metadata: - name: consumerID value: '{uuid}' @@ -56,3 +37,16 @@ spec: value: tcp://admin:public@emqx:1883 - name: qos value: 1 + type: pubsub.mqtt + version: v1 + template: + containers: + - imagePullPolicy: IfNotPresent + name: function + triggers: + dapr: + - name: mqtt-pubsub + topic: sub + type: pubsub.mqtt + version: v2.0.0 + workloadRuntime: OCIContainer diff --git a/functions/async/pubsub/subscriber/function-subscriber.yaml b/functions/async/pubsub/subscriber/function-subscriber.yaml index 60ed1d7..5ad4667 100644 --- a/functions/async/pubsub/subscriber/function-subscriber.yaml +++ b/functions/async/pubsub/subscriber/function-subscriber.yaml @@ -1,68 +1,70 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: autoscaling-subscriber + namespace: default spec: - version: "v2.0.0" - image: openfunctiondev/autoscaling-subscriber:v1 - imageCredentials: - name: push-secret build: builder: openfunction/builder-go:latest env: - FUNC_NAME: "Subscriber" FUNC_CLEAR_SOURCE: "true" -# # Use FUNC_GOPROXY to set the goproxy if failed to fetch go modules -# FUNC_GOPROXY: "https://goproxy.cn" + FUNC_NAME: Subscriber + # # Use FUNC_GOPROXY to set the goproxy if failed to fetch go modules + # FUNC_GOPROXY: "https://goproxy.cn" srcRepo: - url: "https://github.com/OpenFunction/samples.git" - sourceSubPath: "functions/async/pubsub/subscriber" - revision: "main" + revision: main + sourceSubPath: functions/async/pubsub/subscriber + url: https://github.com/OpenFunction/samples.git + image: openfunctiondev/autoscaling-subscriber:v1 + imageCredentials: + name: push-secret serving: - runtime: "async" + pubsub: + kafka-server: + metadata: + - name: brokers + value: kafka-server-kafka-brokers:9092 + - name: authRequired + value: "false" + - name: allowedTopics + value: sample-topic + - name: consumerID + value: autoscaling-subscriber + type: pubsub.kafka + version: v1 scaleOptions: keda: scaledObject: - pollingInterval: 15 - minReplicaCount: 0 - maxReplicaCount: 10 - cooldownPeriod: 60 advanced: horizontalPodAutoscalerConfig: behavior: scaleDown: - stabilizationWindowSeconds: 45 policies: - - type: Percent - value: 50 - periodSeconds: 15 + - periodSeconds: 15 + type: Percent + value: 50 + stabilizationWindowSeconds: 45 scaleUp: stabilizationWindowSeconds: 0 - triggers: - - type: kafka - metadata: - topic: "sample-topic" - bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092 - consumerGroup: autoscaling-subscriber - lagThreshold: "20" + cooldownPeriod: 60 + pollingInterval: 15 + triggers: + - metadata: + bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092 + consumerGroup: autoscaling-subscriber + lagThreshold: "20" + topic: sample-topic + type: kafka + maxReplicas: 10 + minReplicas: 0 template: containers: - - name: function # DO NOT change this - imagePullPolicy: IfNotPresent - inputs: - - name: producer - component: kafka-server - topic: "sample-topic" - pubsub: - kafka-server: - type: pubsub.kafka - version: v1 - metadata: - - name: brokers - value: "kafka-server-kafka-brokers:9092" - - name: authRequired - value: "false" - - name: allowedTopics - value: "sample-topic" - - name: consumerID - value: "autoscaling-subscriber" + - imagePullPolicy: IfNotPresent + name: function + triggers: + dapr: + - name: kafka-server + topic: sample-topic + type: pubsub.kafka + version: v2.0.0 + workloadRuntime: OCIContainer diff --git a/functions/knative/greeting-node/greeting.yaml b/functions/knative/greeting-node/greeting.yaml index 0ddaa4d..bbf6130 100644 --- a/functions/knative/greeting-node/greeting.yaml +++ b/functions/knative/greeting-node/greeting.yaml @@ -1,4 +1,4 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: sample-node-knative @@ -15,17 +15,17 @@ spec: # url: https://github.com/OpenFunction/samples.git # sourceSubPath: functions/async/mqtt-io-node # revision: main - # app port default to "8080" - # port: 8080 serving: - runtime: knative scaleOptions: minReplicas: 0 maxReplicas: 2 template: containers: - name: function # DO NOT change this - imagePullPolicy: IfNotPresent + imagePullPolicy: IfNotPresent + triggers: + http: + port: 8080 params: # default to "production" NODE_ENV: dev diff --git a/functions/knative/hello-world-dotnet/README.md b/functions/knative/hello-world-dotnet/README.md index eb782e4..264e260 100644 --- a/functions/knative/hello-world-dotnet/README.md +++ b/functions/knative/hello-world-dotnet/README.md @@ -8,7 +8,7 @@ Definition of a ```Function``` for ```dotnet``` is shown below: ```yaml -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: dotnet-sample @@ -17,7 +17,6 @@ spec: image: "/sample-dotnet-func:v1" imageCredentials: name: push-secret - port: 8080 # default to 8080 build: builder: "openfunction/gcp-builder:v1" env: @@ -28,9 +27,11 @@ spec: sourceSubPath: "functions/knative/hello-world-dotnet" revision: "release-0.6" serving: - runtime: "knative" # default to knative template: containers: - name: function # DO NOT change this imagePullPolicy: IfNotPresent + triggers: + http: + port: 8080 ``` diff --git a/functions/knative/hello-world-go/function-sample.yaml b/functions/knative/hello-world-go/function-sample.yaml index 692f9a5..9a1eb62 100644 --- a/functions/knative/hello-world-go/function-sample.yaml +++ b/functions/knative/hello-world-go/function-sample.yaml @@ -1,4 +1,4 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: function-sample @@ -7,7 +7,6 @@ spec: image: "openfunctiondev/sample-go-func:v1" imageCredentials: name: push-secret - port: 8080 # default to 8080 build: builder: openfunction/builder-go:latest env: @@ -24,4 +23,6 @@ spec: containers: - name: function # DO NOT change this imagePullPolicy: IfNotPresent - runtime: "knative" + triggers: + http: + port: 8080 diff --git a/functions/knative/hello-world-node/commonjs/function-sample.yaml b/functions/knative/hello-world-node/commonjs/function-sample.yaml index e28bb91..36c4a05 100644 --- a/functions/knative/hello-world-node/commonjs/function-sample.yaml +++ b/functions/knative/hello-world-node/commonjs/function-sample.yaml @@ -1,4 +1,4 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: node-sample @@ -7,7 +7,6 @@ spec: image: "/sample-node-func:v1" imageCredentials: name: push-secret - port: 8080 # default to 8080 build: builder: "openfunction/builder-node:latest" env: @@ -18,8 +17,10 @@ spec: sourceSubPath: "functions/knative/hello-world-node/commonjs" revision: "main" serving: - runtime: "knative" # default to knative template: containers: - name: function # DO NOT change this imagePullPolicy: IfNotPresent + triggers: + http: + port: 8080 diff --git a/functions/knative/hello-world-node/esm/function-sample.yaml b/functions/knative/hello-world-node/esm/function-sample.yaml index f74f5ac..5750809 100644 --- a/functions/knative/hello-world-node/esm/function-sample.yaml +++ b/functions/knative/hello-world-node/esm/function-sample.yaml @@ -1,4 +1,4 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: node-sample @@ -7,7 +7,6 @@ spec: image: "/sample-node-esm-func:v1" imageCredentials: name: push-secret - port: 8080 # default to 8080 build: builder: "openfunction/builder-node:latest" env: @@ -23,3 +22,6 @@ spec: containers: - name: function # DO NOT change this imagePullPolicy: IfNotPresent + triggers: + http: + port: 8080 diff --git a/functions/knative/hello-world-python/README.md b/functions/knative/hello-world-python/README.md index e034adb..e39e3f7 100644 --- a/functions/knative/hello-world-python/README.md +++ b/functions/knative/hello-world-python/README.md @@ -29,7 +29,7 @@ curl http://localhost:8080 Definition of a `Function` for `python` is shown below: ```yaml -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: python-sample @@ -38,7 +38,6 @@ spec: image: "/sample-python-func:v1" imageCredentials: name: push-secret - port: 8080 # default to 8080 build: builder: "openfunction/gcp-builder:v1" env: @@ -55,4 +54,7 @@ spec: containers: - name: function # DO NOT change this imagePullPolicy: IfNotPresent + triggers: + http: + port: 8080 ``` diff --git a/functions/knative/java/cloudevent/function-sample.yaml b/functions/knative/java/cloudevent/function-sample.yaml index e356e39..8688e4d 100644 --- a/functions/knative/java/cloudevent/function-sample.yaml +++ b/functions/knative/java/cloudevent/function-sample.yaml @@ -1,4 +1,4 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: function-cloudevent-java @@ -7,7 +7,6 @@ spec: image: "openfunctiondev/sample-cloudevent-func:v1" imageCredentials: name: push-secret - port: 8080 # default to 8080 build: builder: openfunction/builder-java:v2-18 env: @@ -22,4 +21,7 @@ spec: containers: - name: function # DO NOT change this imagePullPolicy: IfNotPresent - runtime: "knative" + triggers: + http: + port: 8080 + diff --git a/functions/knative/java/hello-world/function-sample.yaml b/functions/knative/java/hello-world/function-sample.yaml index 6143c3f..651bb25 100644 --- a/functions/knative/java/hello-world/function-sample.yaml +++ b/functions/knative/java/hello-world/function-sample.yaml @@ -1,4 +1,4 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: function-http-java @@ -7,7 +7,6 @@ spec: image: "openfunctiondev/sample-java-func:v1" imageCredentials: name: push-secret - port: 8080 # default to 8080 build: builder: openfunction/builder-java:v2-18 env: @@ -22,4 +21,6 @@ spec: containers: - name: function # DO NOT change this imagePullPolicy: IfNotPresent - runtime: "knative" + triggers: + http: + port: 8080 diff --git a/functions/knative/java/with-output-binding/function-front.yaml b/functions/knative/java/with-output-binding/function-front.yaml index 4b41925..d527d7c 100644 --- a/functions/knative/java/with-output-binding/function-front.yaml +++ b/functions/knative/java/with-output-binding/function-front.yaml @@ -1,19 +1,12 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: function-front - annotations: - plugins: | - pre: - - dev.openfunction.samples.plugins.ExamplePlugin - post: - - dev.openfunction.samples.plugins.ExamplePlugin spec: version: "v1.0.0" image: "openfunctiondev/sample-knative-dapr-java:v1" imageCredentials: name: push-secret - port: 8080 # default to 8080 build: builder: openfunction/builder-java:v2-18 env: @@ -24,14 +17,19 @@ spec: sourceSubPath: "functions/knative/java" revision: "main" serving: + hooks: + post: + - dev.openfunction.samples.plugins.ExamplePlugin + pre: + - dev.openfunction.samples.plugins.ExamplePlugin scaleOptions: minReplicas: 0 maxReplicas: 5 - runtime: knative outputs: - - name: target - component: kafka-server - operation: "create" + - dapr: + name: target + operation: "create" + type: bindings.kafka bindings: kafka-server: type: bindings.kafka @@ -51,3 +49,6 @@ spec: containers: - name: function # DO NOT change this imagePullPolicy: IfNotPresent + triggers: + http: + port: 8080 \ No newline at end of file diff --git a/functions/knative/logs-handler-function/logs-handler-function.yaml b/functions/knative/logs-handler-function/logs-handler-function.yaml index 5e4fac6..e1c0aea 100644 --- a/functions/knative/logs-handler-function/logs-handler-function.yaml +++ b/functions/knative/logs-handler-function/logs-handler-function.yaml @@ -1,4 +1,4 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: logs-sync-handler @@ -19,8 +19,10 @@ spec: sourceSubPath: "functions/knative/logs-handler-function/" revision: "main" serving: - runtime: "knative" template: containers: - name: function # DO NOT change this - imagePullPolicy: IfNotPresent + imagePullPolicy: IfNotPresent + triggers: + http: + port: 8080 diff --git a/functions/knative/multiple-functions-go/function-sample.yaml b/functions/knative/multiple-functions-go/function-sample.yaml index 9b48119..ab91270 100644 --- a/functions/knative/multiple-functions-go/function-sample.yaml +++ b/functions/knative/multiple-functions-go/function-sample.yaml @@ -1,4 +1,4 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: function-sample @@ -7,7 +7,6 @@ spec: image: "openfunctiondev/sample-go-multi-func:latest" imageCredentials: name: push-secret - port: 8080 # default to 8080 build: builder: openfunction/builder-go:latest env: @@ -24,4 +23,6 @@ spec: containers: - name: function imagePullPolicy: Always - runtime: "knative" + triggers: + http: + port: 8080 diff --git a/functions/knative/path-parameters-function-go/function-sample.yaml b/functions/knative/path-parameters-function-go/function-sample.yaml index bffcaa8..455bf8d 100644 --- a/functions/knative/path-parameters-function-go/function-sample.yaml +++ b/functions/knative/path-parameters-function-go/function-sample.yaml @@ -1,4 +1,4 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: function-sample @@ -7,7 +7,6 @@ spec: image: "/sample-go-path-params-func:v1" imageCredentials: name: push-secret - port: 8080 # default to 8080 build: builder: openfunction/builder-go:v2.4.0-1.17 env: @@ -24,7 +23,9 @@ spec: containers: - name: function imagePullPolicy: Always - runtime: "knative" + triggers: + http: + port: 8080 annotations: # to enable dapr manually # Dapr annotations: https://docs.dapr.io/reference/arguments-annotations-overview/ diff --git a/functions/knative/wasmedge/http-server/wasmedge-http-server.yaml b/functions/knative/wasmedge/http-server/wasmedge-http-server.yaml index d7c1283..c6d389e 100644 --- a/functions/knative/wasmedge/http-server/wasmedge-http-server.yaml +++ b/functions/knative/wasmedge/http-server/wasmedge-http-server.yaml @@ -1,4 +1,4 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: wasmedge-http-server @@ -13,15 +13,7 @@ spec: revision: main sourceSubPath: functions/knative/wasmedge/http-server url: https://github.com/OpenFunction/samples - port: 8080 - route: - rules: - - matches: - - path: - type: PathPrefix - value: /echo serving: - runtime: knative scaleOptions: minReplicas: 0 template: @@ -34,4 +26,13 @@ spec: periodSeconds: 30 tcpSocket: port: 8080 - name: function \ No newline at end of file + name: function + triggers: + http: + port: 8080 + route: + rules: + - matches: + - path: + type: PathPrefix + value: /echo \ No newline at end of file diff --git a/functions/knative/with-output-binding-node/http-trigger.yaml b/functions/knative/with-output-binding-node/http-trigger.yaml index e5aa9e6..d3717c1 100644 --- a/functions/knative/with-output-binding-node/http-trigger.yaml +++ b/functions/knative/with-output-binding-node/http-trigger.yaml @@ -1,4 +1,4 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: sample-node-http-trigger @@ -15,11 +15,7 @@ spec: # url: https://github.com/OpenFunction/samples.git # sourceSubPath: functions/async/mqtt-io-node # revision: main - # app port default to "8080" - # port: 8080 serving: - # default to knative - runtime: knative scaleOptions: minReplicas: 0 maxReplicas: 2 @@ -40,9 +36,9 @@ spec: FUNCTION_SIGNATURE_TYPE: openfunction DEBUG: common:*,ofn:* outputs: - - name: mqtt-output - component: mqtt-out - operation: create + - dapr: + name: mqtt-out + type: bindings.mqtt bindings: # Dapr MQTT Binding: https://docs.dapr.io/reference/components-reference/supported-bindings/mqtt/ mqtt-out: @@ -55,3 +51,6 @@ spec: value: tcp://admin:public@emqx:1883 - name: topic value: out + triggers: + http: + port: 8080 diff --git a/functions/knative/with-output-binding/function-front.yaml b/functions/knative/with-output-binding/function-front.yaml index 7ab8614..cebbfb2 100644 --- a/functions/knative/with-output-binding/function-front.yaml +++ b/functions/knative/with-output-binding/function-front.yaml @@ -1,21 +1,12 @@ -apiVersion: core.openfunction.io/v1beta1 +apiVersion: core.openfunction.io/v1beta2 kind: Function metadata: name: function-front - annotations: - plugins: | - pre: - - plugin-custom - - plugin-example - post: - - plugin-custom - - plugin-example spec: version: "v1.0.0" image: "openfunctiondev/sample-knative-dapr:v1" imageCredentials: name: push-secret - port: 8080 # default to 8080 build: builder: openfunction/builder-go:latest env: @@ -28,14 +19,20 @@ spec: sourceSubPath: "functions/knative/with-output-binding" revision: "main" serving: + hooks: + post: + - plugin-example + - plugin-custom + pre: + - plugin-custom + - plugin-example scaleOptions: minReplicas: 0 maxReplicas: 5 - runtime: knative outputs: - - name: target - component: kafka-server - operation: "create" + - dapr: + name: kafka-server + operation: "create" bindings: kafka-server: type: bindings.kafka @@ -54,4 +51,7 @@ spec: template: containers: - name: function # DO NOT change this - imagePullPolicy: IfNotPresent + imagePullPolicy: IfNotPresent + triggers: + http: + port: 8080 diff --git a/functions/tracing/README.md b/functions/tracing/README.md index 107c146..fb69784 100644 --- a/functions/tracing/README.md +++ b/functions/tracing/README.md @@ -85,10 +85,12 @@ We provide two ways to enable the function tracing capability: key: "key1" value: "value1" ``` + +> After API version v1beta2, the key changed to `data.tracing`. - Function-level configuration - You should add `plugins.tracing` in the `metadata.annotations` in Function spec. + With API version v1beta1, you should add `plugins.tracing` in the `metadata.annotations` in Function spec. ```yaml metadata: @@ -109,6 +111,26 @@ We provide two ways to enable the function tracing capability: value: "value1" ``` + With API version v1beta2, you should set like this. + + ```yaml + spec: + serving: + tracing: + enabled: true + provider: + name: "skywalking" + oapServer: "skywalking-oap:11800" + tags: + func: tracing-function + layer: faas + tag1: value1 + tag2: value2 + baggage: + key: "key1" + value: "value1" + ``` + Then we can follow [this guide](https://github.com/OpenFunction/samples/blob/main/functions/knative/with-output-binding/README.md#deployment) (it recommends using the global tracing configuration, otherwise, you need to add function-level tracing configuration for both functions based on this sample) to deploy two functions for demonstrating the tracing effect of the entire link. ## Result