Skip to content

Commit 05acedf

Browse files
update docs for API v1beta2 (#356)
* update docs for API v1beta2 Signed-off-by: wanjunlei <wanjunlei@kubesphere.io> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/function_trigger.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/function_trigger.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/function_trigger.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/function_trigger.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/function_trigger.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/build_strategy.md Co-authored-by: Benjamin Huo <huobj@qq.com> * Update content/en/docs/concepts/function_trigger.md Co-authored-by: Benjamin Huo <huobj@qq.com> * readd the docs about pack build Signed-off-by: wanjunlei <wanjunlei@kubesphere.io> --------- Signed-off-by: wanjunlei <wanjunlei@kubesphere.io> Co-authored-by: Benjamin Huo <huobj@qq.com>
1 parent f99d6a1 commit 05acedf

23 files changed

+808
-587
lines changed

content/en/docs/best-practices/interact-with-dapr-output-binding.md

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ The following diagram illustrates the relationship between these functions.
114114
1. Use the following example YAML file to create a manifest `kafka-input.yaml` and modify the value of `spec.image` to set your own image registry address. The field `spec.serving.inputs` defines an input source that points to a Dapr component of the Kafka server. It means that the `kafka-input` function will be driven by events in the topic `sample-topic` of the Kafka server.
115115

116116
```yaml
117-
apiVersion: core.openfunction.io/v1beta1
117+
apiVersion: core.openfunction.io/v1beta2
118118
kind: Function
119119
metadata:
120120
name: kafka-input
@@ -133,15 +133,19 @@ The following diagram illustrates the relationship between these functions.
133133
sourceSubPath: "functions/async/bindings/kafka-input"
134134
revision: "main"
135135
serving:
136-
runtime: async
137136
scaleOptions:
138137
minReplicas: 0
139138
maxReplicas: 10
140139
keda:
140+
triggers:
141+
- type: kafka
142+
metadata:
143+
topic: sample-topic
144+
bootstrapServers: kafka-server-kafka-brokers.default.svc:9092
145+
consumerGroup: kafka-input
146+
lagThreshold: "20"
141147
scaledObject:
142148
pollingInterval: 15
143-
minReplicaCount: 0
144-
maxReplicaCount: 10
145149
cooldownPeriod: 60
146150
advanced:
147151
horizontalPodAutoscalerConfig:
@@ -154,16 +158,11 @@ The following diagram illustrates the relationship between these functions.
154158
periodSeconds: 15
155159
scaleUp:
156160
stabilizationWindowSeconds: 0
161+
157162
triggers:
158-
- type: kafka
159-
metadata:
160-
topic: sample-topic
161-
bootstrapServers: kafka-server-kafka-brokers.default.svc:9092
162-
consumerGroup: kafka-input
163-
lagThreshold: "20"
164-
inputs:
165-
- name: greeting
166-
component: target-topic
163+
dapr:
164+
- name: target-topic
165+
type: bindings.kafka
167166
bindings:
168167
target-topic:
169168
type: bindings.kafka
@@ -192,26 +191,17 @@ The following diagram illustrates the relationship between these functions.
192191
```
193192

194193
3. Use the following example YAML file to create a manifest `function-front.yaml` and modify the value of `spec.image` to set your own image registry address.
195-
196-
```yaml
197-
apiVersion: core.openfunction.io/v1beta1
194+
195+
```yaml
196+
apiVersion: core.openfunction.io/v1beta2
198197
kind: Function
199198
metadata:
200199
name: function-front
201-
annotations:
202-
plugins: |
203-
pre:
204-
- plugin-custom
205-
- plugin-example
206-
post:
207-
- plugin-custom
208-
- plugin-example
209200
spec:
210201
version: "v1.0.0"
211202
image: "<your registry name>/sample-knative-dapr:latest"
212203
imageCredentials:
213204
name: push-secret
214-
port: 8080 # Default to 8080
215205
build:
216206
builder: openfunction/builder-go:latest
217207
env:
@@ -222,14 +212,20 @@ The following diagram illustrates the relationship between these functions.
222212
sourceSubPath: "functions/knative/with-output-binding"
223213
revision: "main"
224214
serving:
215+
hooks:
216+
pre:
217+
- plugin-custom
218+
- plugin-example
219+
post:
220+
- plugin-example
221+
- plugin-custom
225222
scaleOptions:
226223
minReplicas: 0
227224
maxReplicas: 5
228-
runtime: knative
229225
outputs:
230-
- name: target
231-
component: kafka-server
232-
operation: "create"
226+
- dapr:
227+
name: kafka-server
228+
operation: "create"
233229
bindings:
234230
kafka-server:
235231
type: bindings.kafka
@@ -249,8 +245,8 @@ The following diagram illustrates the relationship between these functions.
249245
containers:
250246
- name: function
251247
imagePullPolicy: Always
252-
```
253-
248+
```
249+
254250
{{% alert title="Note" color="success" %}}
255251

256252
`metadata.plugins.pre` defines the order of plugins that need to be called before the user function is executed. `metadata.plugins.post` defines the order of plugins that need to be called after the user function is executed. For more information about the logic of these two plugins and the effect of the plugins after they are executed, see [Plugin mechanism](https://github.com/OpenFunction/samples/blob/main/functions-framework/README.md#plugin-mechanism).

content/en/docs/best-practices/logs-handler-function.md

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -111,87 +111,89 @@ This document uses an asynchronous function to analyze the log stream in Kafka t
111111

112112
1. Use the following example YAML file to create a manifest `logs-handler-function.yaml` and modify the value of `spec.image` to set your own image registry address.
113113

114-
```yaml
115-
apiVersion: core.openfunction.io/v1beta1
114+
```yaml
115+
apiVersion: core.openfunction.io/v1beta2
116116
kind: Function
117117
metadata:
118118
name: logs-async-handler
119+
namespace: default
119120
spec:
120-
version: "v2.0.0"
121-
image: <your registry name>/logs-async-handler:latest
122-
imageCredentials:
123-
name: push-secret
124121
build:
125122
builder: openfunction/builder-go:latest
126123
env:
127-
FUNC_NAME: "LogsHandler"
128124
FUNC_CLEAR_SOURCE: "true"
129-
# Use FUNC_GOPROXY to set the goproxy
130-
# FUNC_GOPROXY: "https://goproxy.cn"
125+
FUNC_NAME: LogsHandler
131126
srcRepo:
132-
url: "https://github.com/OpenFunction/samples.git"
133-
sourceSubPath: "functions/async/logs-handler-function/"
134-
revision: "main"
127+
revision: main
128+
sourceSubPath: functions/async/logs-handler-function/
129+
url: https://github.com/OpenFunction/samples.git
130+
image: openfunctiondev/logs-async-handler:v1
131+
imageCredentials:
132+
name: push-secret
135133
serving:
136-
runtime: "async"
137-
scaleOptions:
138-
keda:
139-
scaledObject:
140-
pollingInterval: 15
141-
minReplicaCount: 0
142-
maxReplicaCount: 10
143-
cooldownPeriod: 60
144-
advanced:
145-
horizontalPodAutoscalerConfig:
146-
behavior:
147-
scaleDown:
148-
stabilizationWindowSeconds: 45
149-
policies:
150-
- type: Percent
151-
value: 50
152-
periodSeconds: 15
153-
scaleUp:
154-
stabilizationWindowSeconds: 0
155-
triggers:
156-
- type: kafka
157-
metadata:
158-
topic: logs
159-
bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092
160-
consumerGroup: logs-handler
161-
lagThreshold: "20"
162-
template:
163-
containers:
164-
- name: function
165-
imagePullPolicy: Always
166-
inputs:
167-
- name: kafka
168-
component: kafka-receiver
169-
outputs:
170-
- name: notify
171-
component: notification-manager
172-
operation: "post"
173134
bindings:
174135
kafka-receiver:
175-
type: bindings.kafka
176-
version: v1
177136
metadata:
178137
- name: brokers
179-
value: "kafka-server-kafka-brokers:9092"
138+
value: kafka-server-kafka-brokers:9092
180139
- name: authRequired
181140
value: "false"
182141
- name: publishTopic
183-
value: "logs"
142+
value: logs
184143
- name: topics
185-
value: "logs"
144+
value: logs
186145
- name: consumerGroup
187-
value: "logs-handler"
188-
notification-manager:
189-
type: bindings.http
146+
value: logs-handler
147+
type: bindings.kafka
190148
version: v1
149+
notification-manager:
191150
metadata:
192151
- name: url
193152
value: http://notification-manager-svc.kubesphere-monitoring-system.svc.cluster.local:19093/api/v2/alerts
194-
```
153+
type: bindings.http
154+
version: v1
155+
outputs:
156+
- dapr:
157+
name: notification-manager
158+
operation: post
159+
type: bindings.http
160+
scaleOptions:
161+
keda:
162+
scaledObject:
163+
advanced:
164+
horizontalPodAutoscalerConfig:
165+
behavior:
166+
scaleDown:
167+
policies:
168+
- periodSeconds: 15
169+
type: Percent
170+
value: 50
171+
stabilizationWindowSeconds: 45
172+
scaleUp:
173+
stabilizationWindowSeconds: 0
174+
cooldownPeriod: 60
175+
pollingInterval: 15
176+
triggers:
177+
- metadata:
178+
bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092
179+
consumerGroup: logs-handler
180+
lagThreshold: "20"
181+
topic: logs
182+
type: kafka
183+
maxReplicas: 10
184+
minReplicas: 0
185+
template:
186+
containers:
187+
- imagePullPolicy: IfNotPresent
188+
name: function
189+
triggers:
190+
dapr:
191+
- name: kafka-receiver
192+
type: bindings.kafka
193+
workloadType: Deployment
194+
version: v2.0.0
195+
workloadRuntime: OCIContainer
196+
```
195197

196198
2. Run the following command to create the function `logs-async-handler`.
197199

content/en/docs/best-practices/skywalking-solution-for-openfunction.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ This document uses `skywalking-oap.default:11800` as an example of the skywalkin
7272

7373
```yaml
7474
data:
75-
plugins.tracing: |
75+
tracing: |
7676
enabled: true
7777
provider:
7878
name: "skywalking"
@@ -94,20 +94,21 @@ To enable tracing configuration in the function-level, add the field `plugins.tr
9494
```yaml
9595
metadata:
9696
name: tracing-function
97-
annotations:
98-
plugins.tracing: |
99-
enabled: true
100-
provider:
101-
name: "skywalking"
102-
oapServer: "skywalking-oap:11800"
103-
tags:
104-
func: tracing-function
105-
layer: faas
106-
tag1: value1
107-
tag2: value2
108-
baggage:
109-
key: "key1"
110-
value: "value1"
97+
spec:
98+
serving:
99+
tracing:
100+
enabled: true
101+
provider:
102+
name: "skywalking"
103+
oapServer: "skywalking-oap:11800"
104+
tags:
105+
func: tracing-function
106+
layer: faas
107+
tag1: value1
108+
tag2: value2
109+
baggage:
110+
key: "key1"
111+
value: "value1"
111112
```
112113

113114
It is recommended that you use the global tracing configuration, or you have to add function-level tracing configuration for every function you create.

content/en/docs/concepts/Events/event-bus-and-trigger.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,33 @@ helm install stan nats/stan --set stan.nats.url=nats://nats:4222
2727
1. Use the following content to create a configuration file (for example, `openfuncasync-function.yaml`) for the target function, which is triggered by the Trigger CRD and prints the received message.
2828

2929
```yaml
30-
apiVersion: core.openfunction.io/v1beta1
30+
apiVersion: core.openfunction.io/v1beta2
3131
kind: Function
3232
metadata:
3333
name: trigger-target
3434
spec:
3535
version: "v1.0.0"
3636
image: openfunctiondev/v1beta1-trigger-target:latest
37-
port: 8080
3837
serving:
39-
runtime: "async"
4038
scaleOptions:
4139
keda:
4240
scaledObject:
4341
pollingInterval: 15
4442
minReplicaCount: 0
4543
maxReplicaCount: 10
4644
cooldownPeriod: 30
45+
triggers:
46+
- type: stan
47+
metadata:
48+
natsServerMonitoringEndpoint: "stan.default.svc.cluster.local:8222"
49+
queueGroup: "grp1"
50+
durableName: "ImDurable"
51+
subject: "metrics"
52+
lagThreshold: "10"
4753
triggers:
48-
- type: stan
49-
metadata:
50-
natsServerMonitoringEndpoint: "stan.default.svc.cluster.local:8222"
51-
queueGroup: "grp1"
52-
durableName: "ImDurable"
53-
subject: "metrics"
54-
lagThreshold: "10"
55-
inputs:
56-
- name: autoscaling-pubsub
57-
component: eventbus
58-
topic: metrics
54+
dapr:
55+
- name: eventbus
56+
topic: metrics
5957
pubsub:
6058
eventbus:
6159
type: pubsub.natsstreaming
@@ -233,7 +231,7 @@ helm install stan nats/stan --set stan.nats.url=nats://nats:4222
233231
1. Use the following content to create an event producer configuration file (for example, `events-producer.yaml`).
234232

235233
```yaml
236-
apiVersion: core.openfunction.io/v1beta1
234+
apiVersion: core.openfunction.io/v1beta2
237235
kind: Function
238236
metadata:
239237
name: events-producer
@@ -245,14 +243,14 @@ helm install stan nats/stan --set stan.nats.url=nats://nats:4222
245243
containers:
246244
- name: function
247245
imagePullPolicy: Always
248-
runtime: "async"
249-
inputs:
250-
- name: cron
251-
component: cron
246+
triggers:
247+
dapr:
248+
- name: cron
249+
type: bindings.cron
252250
outputs:
253-
- name: target
254-
component: kafka-server
255-
operation: "create"
251+
- dapr:
252+
name: kafka-server
253+
operation: "create"
256254
bindings:
257255
cron:
258256
type: bindings.cron

0 commit comments

Comments
 (0)