OpenFunction icon indicating copy to clipboard operation
OpenFunction copied to clipboard

OpenFunction Dapr elastic Apps

Open wanjunlei opened this issue 4 years ago • 7 comments

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: "" will be automatically injected.

Users need to manage dapr components, including configuration, components, and subscriptions

Supported annotations

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

wanjunlei avatar Feb 10 '22 06:02 wanjunlei

We might need a better runtime name other than just Dapr @tpiperatgod @wanjunlei , any thoughts?

benjaminhuo avatar Feb 10 '22 06:02 benjaminhuo

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 ""

benjaminhuo avatar Feb 14 '22 02:02 benjaminhuo

  • 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

tpiperatgod avatar Feb 14 '22 02:02 tpiperatgod

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 avatar Mar 07 '22 22:03 yaron2

@yaron2 Thanks for the invitation! And yes we're excited to share with Dapr community the important role Dapr plays in OpenFunction.

benjaminhuo avatar Mar 08 '22 01:03 benjaminhuo

@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).

yaron2 avatar Mar 08 '22 01:03 yaron2

Yep, Mar 22nd is ok for us. I'll add a short description to the issue.

Thanks

benjaminhuo avatar Mar 08 '22 04:03 benjaminhuo