OpenFunction Dapr elastic Apps
Proposal
-
Goals OpenFunction Dapr elastic Apps runtime used to run the native dapr app, and autoscale using keda.
-
Example
A function using Dapr elastic Apps runtime may be like this.
apiVersion: core.openfunction.io/v1beta1
kind: Function
metadata:
name: dapr
spec:
version: "v1.0.0"
image: openfunctiondev/dapr-app:latest
serving:
template:
containers:
- name: function
imagePullPolicy: Always
runtime: "dapr"
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: myapp
scaleOptions:
maxReplicas: 10
minReplicas: 1
keda:
scaledObject:
pollingInterval: 15
minReplicaCount: 0
maxReplicaCount: 10
cooldownPeriod: 30
triggers:
- type: kafka
metadata:
topic: "sample-topic"
bootstrapServers: kafka-server-kafka-brokers.default.svc.cluster.local:9092
consumerGroup: autoscaling-subscriber
lagThreshold: "10"
It should not set the build of function when using dapr elastic apps runtime. The user needs to provide an image of the dapr app.
The user controls the dapr sidecar through annotation, and the annotation "dapr.io/enabled: true" will be injected automatically. It is strongly recommended that users set the "dapr.io/app-id" annotation. If not set, annotation "dapr.io/app-id: "
Users need to manage dapr components, including configuration, components, and subscriptions
| Annotations | Description |
|---|---|
| dapr.io/app-id | The unique ID of the application. Used for service discovery, state encapsulation and the pub/sub consumer ID |
| dapr.io/app-port | This parameter tells Dapr which port your application is listening on |
| dapr.io/app-ssl | Sets the URI scheme of the app to https and attempts an SSL connection |
| dapr.io/config | Tells Dapr which Configuration CRD to use |
| dapr.io/http-max-request-size | Increasing max size of request body http and grpc servers parameter in MB to handle uploading of big files. Default is 4 MB |
| dapr.io/sidecar-image | Dapr sidecar image. Default is daprio/daprd:latest |
| dapr.io/enable-profiling | Enable profiling |
| dapr.io/log-as-json | Setting this parameter to true outputs logs in JSON format. Default is false |
| dapr.io/log-level | Sets the log level for the Dapr sidecar. Allowed values are debug, info, warn, error. Default is info |
| dapr.io/app-max-concurrency | Limit the concurrency of your application. A valid value is any number larger than 0 |
| dapr.io/metrics-port | Sets the port for the sidecar metrics server. Default is 9090 |
| dapr.io/app-protocol | Tells Dapr which protocol your application is using. Valid options are http and grpc. Default is http |
| dapr.io/graceful-shutdown-seconds | Graceful shutdown duration in seconds for Dapr, the maximum duration before forced shutdown when waiting for all in-progress requests to complete. Defaults to 5. If you are running in Kubernetes mode, this value should not be larger than the Kubernetes termination grace period, who’s default value is 30. |
| dapr.io/enabled | Setting this paramater to true injects the Dapr sidecar into the pod |
| dapr.io/api-token-secret | Tells Dapr which Kubernetes secret to use for token based API authentication. By default this is not set |
| dapr.io/sidecar-listen-addresses | Comma separated list of IP addresses that sidecar will listen to. Defaults to all in standalone mode. Defaults to [::1],127.0.0.1 in Kubernetes. To listen to all IPv4 addresses, use 0.0.0.0. To listen to all IPv6 addresses, use [::]. |
| dapr.io/sidecar-cpu-limit | Maximum amount of CPU that the Dapr sidecar can use. See valid values here. By default this is not set |
| dapr.io/sidecar-memory-limit | Maximum amount of Memory that the Dapr sidecar can use. See valid values here. By default this is not set |
| dapr.io/sidecar-cpu-request | Amount of CPU that the Dapr sidecar requests. See valid values here. By default this is not set |
| dapr.io/sidecar-memory-request | Amount of Memory that the Dapr sidecar requests .See valid values here. By default this is not set |
| dapr.io/sidecar-liveness-probe-delay-seconds | Number of seconds after the sidecar container has started before liveness probe is initiated. Read more here. Default is 3 |
| dapr.io/sidecar-liveness-probe-timeout-seconds | Number of seconds after which the sidecar liveness probe times out. Read more here. Default is 3 |
| dapr.io/sidecar-liveness-probe-period-seconds | How often (in seconds) to perform the sidecar liveness probe. Read more here. Default is 6 |
| dapr.io/sidecar-liveness-probe-threshold | When the sidecar liveness probe fails, Kubernetes will try N times before giving up. In this case, the Pod will be marked Unhealthy. Read more about failureThreshold here. Default is 3 |
| dapr.io/sidecar-readiness-probe-delay-seconds | Number of seconds after the sidecar container has started before readiness probe is initiated. Read more here. Default is 3 |
| dapr.io/sidecar-readiness-probe-timeout-seconds | Number of seconds after which the sidecar readiness probe times out. Read more here. Default is 3 |
| dapr.io/sidecar-readiness-probe-period-seconds | How often (in seconds) to perform the sidecar readiness probe. Read more here. Default is 6 |
| dapr.io/sidecar-readiness-probe-threshold | When the sidecar readiness probe fails, Kubernetes will try N times before giving up. In this case, the Pod will be marked Unready. Read more about failureThreshold here. Default is 3 |
| dapr.io/env | List of environment variable to be injected into the sidecar. Strings consisting of key=value pairs separated by a comma. |
- Action Items
We might need a better runtime name other than just Dapr
@tpiperatgod @wanjunlei , any thoughts?
A few comments:
It should not set the build of function when using dapr elastic apps runtime. The user needs to provide an image of the dapr app.
- User could still utilize the build mechanism to build apps by providing an application-specific buildpack builder such as https://github.com/buildpacks/samples or a dockerfile
It is strongly recommended that users set the "dapr.io/app-id" annotation. If not set, annotation "dapr.io/app-id: "" will be automatically injected.
- Maybe the default app-id could be
<namespace>\<function-name>other than ""
- Maybe the default app-id could be
<namespace>\<function-name>other than ""
I think what @wanjunlei means is that the field "dapr.io/app-id" will be injected automatically. It should remain the same as it is now, i.e. the <namespace>\<function-name> style
Hey everyone, Dapr maintainer here. Excited to see the work ya'll are doing with Dapr in this project. We're here to support you! Please let us know if you'd like to come on a Dapr community call to share what you're doing.
@yaron2 Thanks for the invitation! And yes we're excited to share with Dapr community the important role Dapr plays in OpenFunction.
@yaron2 Thanks for the invitation! And yes we're excited to share with Dapr community the important role Dapr plays in OpenFunction.
Great :)
Would this time slot work for you? https://github.com/dapr/community/issues/143.
If so, please comment on the issue with a short description about what you're going to show and how much time you need (max 20 minutes).
Yep, Mar 22nd is ok for us. I'll add a short description to the issue.
Thanks