Coder Social home page Coder Social logo

openfunction / openfunction Goto Github PK

View Code? Open in Web Editor NEW
1.5K 1.5K 158.0 18.52 MB

Cloud Native Function-as-a-Service Platform (CNCF Sandbox Project)

Home Page: https://openfunction.dev

License: Apache License 2.0

Makefile 1.57% Dockerfile 0.31% Go 94.95% Shell 3.17%
cloud-native faas k8s knative kubernetes serverless

openfunction's Introduction

banner

Cloud native FaaS platform for running Serverless workloads with ease

A+ good first follow on Twitter

๐Ÿ‘€ Overview

OpenFunction is a cloud-native open source FaaS (Function as a Service) platform aiming to let you focus on your business logic without having to maintain the underlying runtime environment and infrastructure. You only need to submit business-related source code in the form of functions.

OpenFunction features include:

  • Cloud agnostic and decoupled with cloud providers' BaaS
  • Pluggable architecture that allows multiple function runtimes
  • Support both sync and async functions
  • Unique async functions support that can consume events directly from event sources
  • Support generating OCI-Compliant container images directly from function source code.
  • Flexible autoscaling between 0 and N
  • Advanced async function autoscaling based on event sources' specific metrics
  • Simplified BaaS integration for both sync and async functions by introducing Dapr
  • Advanced function ingress & traffic management powered by K8s Gateway API
  • Flexible and easy-to-use events management framework

โ˜ธ Architecture

OpenFunction manages its components in the form of Custom Resource Definitions (CRD) throughout the lifecycle of a function, you can find more details in the Concepts section.

OpenFunction Events is OpenFunction's events framework, you can refer to OpenFunction Events for more information.

๐Ÿš€ QuickStart

Install OpenFunction

To install OpenFunction, please refer to Installation Guide.

Create functions

You can find guides to create the sync and async functions in different languages here

Uninstall OpenFunction

To uninstall OpenFunction, please refer to Uninstallation Guide.

FAQ

When you encounter any problems when using OpenFunction, you can refer to the FAQ for help.

๐Ÿ’ป Development

See the Development Guide to get started with developing this project.

๐Ÿ›ฃ๏ธ Roadmap

Here you can find OpenFunction roadmap.

๐Ÿ˜๏ธ Community

Landscape



ย ย ย ย 

OpenFunction is a CNCF Sandbox project now which also enriches the CNCF Cloud Native Landscape.

๐Ÿ“Š Status

Alt

openfunction's People

Contributors

aarush-goyal avatar arugal avatar b1f030 avatar benjaminhuo avatar binnn6 avatar bryce-huang avatar dependabot[bot] avatar felixnoo avatar hurricane1988 avatar james-jlc avatar kezhenxu94 avatar klausmikhaelson avatar lizzzcai avatar shyupc avatar testwill avatar tpiperatgod avatar wanjunlei avatar wentevill avatar wrongerror avatar xjl123456 avatar yangchuansheng avatar zhu733756 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openfunction's Issues

[Feature request]Observability of OpenFunction

Description
A clear and concise description of what the feature is.

Hi OpenFunction team, I checked the roadmap and want to know if OpenFunction support basic logging, metric and tracing. If yes, is there any docs for this? If not, is there any plan on this. Thanks. (referring to #146 (comment))

As a user, I want to know the metrics of the system and the functions (like number of calls etc).
As a user, I want to know the basic tracing of my function calls and time spend, tracing of the event similar to what is showing here.
As a user, I want all these data can be stored and visualized in various open source / commercial product.

Additional context
Add any other context or screenshots about the feature request here.

Function failed to build after renaming the used secret

Description
Function failed to build after renaming or deleting the secret used previously

Environmental
Tell us what your cluster environment is like, e.g.

  • Operating System Information
  • kubernetes version: 1.21.5
  • OpenFunction version: latest
  • Versions of dependent components (e.g. dapr, keda, shipwright, knative)
    • Shipwright: v0.6.0

Expected behavior
The Function should be able to build even the push secret being deleted

Actual behavior
Once I delete the push-secret and create another secret with a different name (push-secret-new), ofn is not able to build the function

To Reproduce

  1. create a push secret: push-secret
  2. build a function
apiVersion: core.openfunction.io/v1alpha2
kind: Function
metadata:
  name: function-sample
spec:
  version: "v1.0.0"
  image: "openfunctiondev/sample-go-func:latest"
  imageCredentials:
    name: push-secret
  port: 8080 # default to 8080
  build:
    builder: openfunction/builder:v1
    env:
      FUNC_NAME: "HelloWorld"
      FUNC_TYPE: "http"
    srcRepo:
      url: "https://github.com/OpenFunction/samples.git"
      sourceSubPath: "functions/Knative/hello-world-go"
  serving:
    runtime: "Knative" # default to Knative
    template:
      containers:
        - name: function
          imagePullPolicy: Always
  1. delete the push-secret and create a new one called: push-secret-new
  2. build the function again
apiVersion: core.openfunction.io/v1alpha2
kind: Function
metadata:
  name: function-sample-new
spec:
  version: "v1.0.0"
  image: "openfunctiondev/sample-go-func:latest"
  imageCredentials:
    name: push-secret-new # <-update the secret
  port: 8080 # default to 8080
  build:
    builder: openfunction/builder:v1
    env:
      FUNC_NAME: "HelloWorld"
      FUNC_TYPE: "http"
    srcRepo:
      url: "https://github.com/OpenFunction/samples.git"
      sourceSubPath: "functions/Knative/hello-world-go"
  serving:
    runtime: "Knative" # default to Knative
    template:
      containers:
        - name: function
          imagePullPolicy: Always
  1. See error
โฏ k get buildrun
NAME                           SUCCEEDED   REASON           STARTTIME   COMPLETIONTIME
builder-lckjg-buildrun-mpgq4   False       CouldntGetTask   2m1s        2m1s

...
    conditions:
    - lastTransitionTime: "2022-01-14T09:17:13Z"
      message: 'failed to create task run pod "builder-lckjg-buildrun-mpgq4-wqfwp":
        translating TaskSpec to Pod: secrets "push-secret" not found. Maybe invalid
        TaskSpec'
      reason: CouldntGetTask
      status: "False"
      type: Succeeded

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

It is an issue from Shipwright, please refer to this issue: shipwright-io/build#969

Can add a proxy to the ofn command ?

I have configured a local 1080 proxy, but I still cannot install it successfully

$ ofn install --all 

The following existing components will be skipped:
        - Knative Serving
        - Tekton Pipelines
        - Keda
 โœ— Dapr - Stopped!
 โœ— Shipwright - Stopped!
 โœ— Cert Manager - Stopped!
 โœ— Ingress - Failed!
 โ‡ฒ Error reports: 
Failed to install Ingress: 
Unable to connect to the server: read tcp 192.168.80.130:59322->185.199.109.133:443: read: connection reset by peer
: exit status 1

Or my proxy configuration is wrong? my proxy configuration :

export http_proxy="http://192.168.80.1:1080"
export https_proxy="http://192.168.80.1:1080"

ofn install panic

Description
ofn install --all will panic when waiting for the installation to complete
Environmental

  • Operating System Information
  • kubernetes version
  • OpenFunction version
  • Versions of dependent components (e.g. dapr, keda, shipwright, knative)
+------------------+---------+
| COMPONENT        | VERSION |
+------------------+---------+
| CertManager      | 1.5.4   |
| OpenFunction     | 0.5.0   |
| DefaultDomain    | 1.0.1   |
| Dapr             | 1.5.1   |
| IngressNginx     | 1.1.0   |
| Knative Serving  | 1.0.1   |
| Kourier          | 1.0.1   |
| Tekton Pipelines | 0.30.0  |
| Keda             | 2.4.0   |
| Shipwright       | 0.6.1   |
+------------------+---------+

Expected behavior
installed successfully

Actual behavior

To Reproduce

Screenshots
image

Additional context
Add any other context about the problem here.

Is the deploy.sh still valid?

As ofn CLI has been officially recommended by the OpenFunction community, and the old install/uninstall scripts deprecation was mentioned in v0.5.0 release notes, is the deploy.sh and delete.sh still valid for the old version of OpenFunction?

Replace the sink.ref in events api with function ingress

Description
Since we already have the Function Ingress, we can use it instead of sink.ref in the events API.

Additional context
If not, we would have to configure the Knative Serving network layer (e.g. kourier)
Using the Function Ingress can help us shield the underlying complex implementation for the user.

Use K8s Gateway API as function's API Gateway

Description
K8s gateway API is the next generation of ingress.
It provides some advanced features like HTTP traffic splitting, Cross-Namespace routing, etc. which is powerful and valuable for FaaS as well to be the function's API Gateway.

More info can be found in:
https://gateway-api.sigs.k8s.io/v1alpha2/guides/getting-started/
https://gateway-api.sigs.k8s.io/concepts/api-overview/
https://gateway-api.sigs.k8s.io/implementations/

To support K8s gateway API, we only need to integrate with Gateway API CRDs to be vendor agnostic.

Any implementation that implements K8s gateway API can be plugged into OpenFunction as API Gateway like:

Now both proposal and PR are welcome

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

Support building functions with Dockerfile

Description
We can extract the application template from the builders and make it a base image, from which we can build function images with a dockerfile and then copy the built binary to the run image.

Additional context
This is a complimentary build approach for the buildpacks method and Shipwright support it

Controller failed because dependent CRD was not found "if kind is a CRD, it should be installed before calling Start"

Description
Controller failed because dependent CRD was not found "if kind is a CRD, it should be installed before calling Start"

Environmental

  • Operating System Information, wsl2 archlinux
  • kubernetes version, k3s v1.23+
  • OpenFunction version, v0.5.0
  • Versions of dependent components (e.g. dapr, keda, shipwright, knative)

Expected behavior
The OpenFunction controller will look for CRDs of all dependent components when it starts. It would fail to start when no required CRDs were found.
We should skip the check about the CRDs of the components that do not need to be installed.

Actual behavior
The controller failed since not find the CRD of Knative Serving.

To Reproduce
Steps to reproduce the behavior:

  1. ofn install --async --shipwright --cert-manager --verbose --region-cn --upgrade --cert-manager
  2. Waiting for the OpenFunction controller to be ready
  3. See the error

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

2022-01-06T05:46:15.627Z        ERROR   controller-runtime.source       if kind is a CRD, it should be installed before calling Start   {"kind": "Service.serving.knative.dev", "error": "no matches for kind \"Service\" in version \"serving.knative.dev/v1\""}
2022-01-06T05:46:15.627Z        ERROR   controller.serving      Could not wait for Cache to sync        {"reconciler group": "core.openfunction.io", "reconciler kind": "Serving", "error": "failed to wait for serving caches to sync: no matches for kind \"Service\" in version \"serving.knative.dev/v1\""}
2022-01-06T05:46:15.627Z        INFO    controller-runtime.webhook      shutting down webhook server
2022-01-06T05:46:15.627Z        ERROR   controller.function     Could not wait for Cache to sync        {"reconciler group": "core.openfunction.io", "reconciler kind": "Function", "error": "failed to wait for function caches to sync: timed out waiting for cache to be synced"}
2022-01-06T05:46:15.627Z        ERROR   error received after stop sequence was engaged  {"error": "failed to wait for function caches to sync: timed out waiting for cache to be synced"}
2022-01-06T05:46:15.627Z        ERROR   controller.trigger      Could not wait for Cache to sync        {"reconciler group": "events.openfunction.io", "reconciler kind": "Trigger", "error": "failed to wait for trigger caches to sync: timed out waiting for cache to be synced"}
2022-01-06T05:46:15.627Z        ERROR   error received after stop sequence was engaged  {"error": "failed to wait for trigger caches to sync: timed out waiting for cache to be synced"}
2022-01-06T05:46:15.627Z        ERROR   controller.domain       Could not wait for Cache to sync        {"reconciler group": "core.openfunction.io", "reconciler kind": "Domain", "error": "failed to wait for domain caches to sync: timed out waiting for cache to be synced"}
2022-01-06T05:46:15.627Z        ERROR   error received after stop sequence was engaged  {"error": "failed to wait for domain caches to sync: timed out waiting for cache to be synced"}
202

curl: (6) Couldn't resolve host 'xxxx' when using xip.io as DNS

When using xip.io as DNS for Knative-serving, I can't resolve to ksvc's url after the function has created.

Got this:

curl: (6) Couldn't resolve host 'xxxx' 

There is a workaround:

  1. Check if you can use Real DNS. Follow the Step 2 if it works otherwise you should check the coredns and nodelocaldns.

  2. When you get into step 2, it means the probability is that xip.io is down and we need to replace xip.io with nip.io, refer to this answer.

    • For Knative-serving has not been deployed

    Edit the yaml in Magic DNS (xip.io) like this:

    -         args: ["-magic-dns=xip.io"]
    +         args: ["-magic-dns=nip.io"]

    Then follow the rest steps.

    • For Knative-serving has been deployed

    You need to modify the configmap config-domain in knative-serving namespace , replace xip.io with nip.io in the domain name with xip.io in the data field.

We will update the documentation for this section later.

Install openfunction failed

Kubectl version

Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"clean", BuildDate:"2021-04-08T16:31:21Z", GoVersion:"go1.16.1", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.1", GitCommit:"5e58841cce77d4bc13713ad2b91fa0d961e69192", GitTreeState:"clean", BuildDate:"2021-05-18T01:15:06Z", GoVersion:"go1.16.4", Compiler:"gc", Platform:"linux/arm64"}

How to install openfunction

kubectl apply -f https://raw.githubusercontent.com/OpenFunction/OpenFunction/main/config/bundle.yaml

namespace/openfunction created
customresourcedefinition.apiextensions.k8s.io/builders.core.openfunction.io created
customresourcedefinition.apiextensions.k8s.io/clustereventbus.events.openfunction.io created
customresourcedefinition.apiextensions.k8s.io/eventbus.events.openfunction.io created
customresourcedefinition.apiextensions.k8s.io/eventsources.events.openfunction.io created
customresourcedefinition.apiextensions.k8s.io/triggers.events.openfunction.io created
mutatingwebhookconfiguration.admissionregistration.k8s.io/openfunction-mutating-webhook-configuration created
serviceaccount/openfunction-controller-manager created
role.rbac.authorization.k8s.io/openfunction-leader-election-role created
clusterrole.rbac.authorization.k8s.io/openfunction-manager-role created
clusterrole.rbac.authorization.k8s.io/openfunction-metrics-reader created
clusterrole.rbac.authorization.k8s.io/openfunction-proxy-role created
rolebinding.rbac.authorization.k8s.io/openfunction-leader-election-rolebinding created
clusterrolebinding.rbac.authorization.k8s.io/openfunction-manager-rolebinding created
clusterrolebinding.rbac.authorization.k8s.io/openfunction-proxy-rolebinding created
configmap/openfunction-manager-config created
service/openfunction-controller-manager-metrics-service created
service/openfunction-webhook-service created
deployment.apps/openfunction-controller-manager created
[unable to recognize "https://raw.githubusercontent.com/OpenFunction/OpenFunction/main/config/bundle.yaml": no matches for kind "Certificate" in version "cert-manager.io/v1", unable to recognize "https://raw.githubusercontent.com/OpenFunction/OpenFunction/main/config/bundle.yaml": no matches for kind "Issuer" in version "cert-manager.io/v1", unable to recognize "https://raw.githubusercontent.com/OpenFunction/OpenFunction/main/config/bundle.yaml": no matches for kind "ClusterBuildStrategy" in version "shipwright.io/v1alpha1"]
Error from server (Invalid): error when creating "https://raw.githubusercontent.com/OpenFunction/OpenFunction/main/config/bundle.yaml": CustomResourceDefinition.apiextensions.k8s.io "functions.core.openfunction.io" is invalid: metadata.annotations: Too long: must have at most 262144 bytes
Error from server (Invalid): error when creating "https://raw.githubusercontent.com/OpenFunction/OpenFunction/main/config/bundle.yaml": CustomResourceDefinition.apiextensions.k8s.io "servings.core.openfunction.io" is invalid: metadata.annotations: Too long: must have at most 262144 bytes

Request feature to preload the run image to nodes to reduce the cold start time

Description

I would like to check if OpenFunction can support customized run images and cache the run images in the host. The target here is to reduce the image size so that can reduce the cool start time.

Use case

for machine learning use cases, there are usually a lot of dependencies like tensorflow, pytorch, opencv etc. The size of these kinds of libraries are quite big (up to 1-2 GB usually) and the actual size of code is about 1-2 MB (not including the models). If the base libraries can be separated and cached in the host machine, The image size of the function can be reduced. I think that will help to reduce the cool start time significantly.

A similar idea is shown in this post for your reference.

An example function yaml for illustration:

apiVersion: core.openfunction.io/v1alpha2
kind: Function
metadata:
  name: iris-python
spec:
  version: "v1.0.0"
  image: "lizzzcai/iris-python-func:v0.4.0"
  imageCredentials:
    name: push-secret
  port: 8080
  # user can define the run image
  runImage: tensorflow/tensorflow:2.2.3-py3 # dependencies to run the python code
  build:
    builder: openfunction/builder:v1
    env:
      FUNC_NAME: "predict"
      FUNC_TYPE: "http"
      FUNC_SRC: "main.py"
    srcRepo:
      url: "https://github.com/lizzzcai/openfunction-samples.git"
      sourceSubPath: "iris-python"
  serving:
    runtime: Knative

Add a todo list for OpenFunction events framework

In PR #83 we set up the basic OpenFunction events framework. There are still some refinement work and feature development tasks that we need to complete.

What can it currently do

  • Ability to handle NATS streaming type EventBus
  • Ability to handle Redis, Kafka, Cron(scheduler) type EventSources
  • EventSources can trigger Knative Service synchronization calls
  • The EventSource can send events to the EventBus(or ClusterEventBus)
  • Triggers can associate EventBus(or ClusterEventBus) and then trigger target functions (including Knative Service function and OpenFuncAsync function)

TODO:

  • #88

  • #97

  • #98

  • #124

  • Add more kinds of event sources, event buses, triggers

  • Add samples && concept docs

Add ability to control function instance pod min and max number at function schema

Description
There are two scenes need to the ability to control function instance pod min number.

  • First
    Need to scale to zero.
  • Second
    Need to remain some number function instance pod even if this function has not been any called. This scene is very useful for sensitive project which has clod startup ใ€pulling large image or long time init.

Upon ability can be supported to users who can decide to scale zero or remain min pod number.

The ability to control function instance pod max number is to protect system security and stability.

Additional context
Keda & Knative all have the ability:
keda: https://keda.sh/docs/2.5/concepts/scaling-deployments/#scaledobject-spec
knative: https://knative.dev/docs/serving/autoscaling/scale-bounds/

Aliyun FC already has the same ability:
https://help.aliyun.com/document_detail/185038.html#title-570-lbv-4b6

Project proposal: OpenFunction CLI

Abstract

OpenFunction requires a command line tool to manage itself and its associated resources.

This command line tool will have the following features:

  • A more elegant way to display logs and progress
    It can collect logs and events of OpenFunction's resources in kubernetes and display them after correlation processing.
  • Targeted resource manipulation
    It will simplify the parameters so that functions can be easily constructed.
    And it will follow the business model and operate on the OpenFunction and its associated resources uniformly, not just on the OpenFunction itself.

Cases

In the case I assume that the CLI is called of

  • Registry

    Create a Registry

    of registry create --name registry_demo --url "https://index.docker.io/v1/" --account some_account
  • Builder

    Create a Builder

    of builder create --name builder_demo --builder somebuilder --src https://github.com/OpenFunction/function-samples.git --subpath hello-world-go --image "<your registry name>/sample-go-func:latest" --registry registry_demo
  • Serving

    Create a Serving

    of serving create --name serving_demo --runtime Knative
  • Function

    Create a Function

    of function create --name function_demo --build builder_demo --serving serving_demo --version v1.0.0

    Describe a Function(just reference tkn)

    Name:              function_demo
    Namespace:         default
    Builder Ref:       builder_demo
    Serving Ref:       serving_demo
    Registry Account:  registry_demo
    Timeout:           1h0m0s
    
    ๐ŸŒก๏ธ  Status
    
    STARTED          DURATION   STATUS
    23 seconds ago   ---        Running
    
    ๐Ÿ“ฆ Resources
    
     No resources
    
    โš“ Params
    
     No params
    
    ๐Ÿ“ Results
    
     No results
    
    ๐Ÿ—‚  Taskruns
    
     NAME              TASK NAME               STARTED          DURATION   STATUS
     โˆ™ function-demo   function-demo-task-1    23 seconds ago   ---        Running

[Discussion] Integration possibility of bundled go2sky

Hi @FeynmanZhou, I want to set up this thread talking about the tech possibility of bundled go2sky.

FaaS is basically highly distributed, even more complex than micro-services or meshed services. With SkyWalking topology and endpoint dependency, we could visualize the function dependency.

image

Build from private repo is not working

Description
Can not build a function from private repo.

Environmental
Tell us what your cluster environment is like, e.g.

  • Operating System Information
  • kubernetes version: 1.21.5
  • OpenFunction version: v0.4.0
  • Versions of dependent components (e.g. dapr, keda, shipwright, knative)
    Shipwright: v0.6.0

Expected behavior
User should be able to create a function from a private repo

Actual behavior
facing error:

2021/12/15 14:49:36 Info: ssh (/usr/bin/ssh): OpenSSH_8.0p1, OpenSSL 1.1.1g FIPS  21 Apr 2020
2021/12/15 14:49:36 Info: git (/usr/bin/git): git version 2.27.0
2021/12/15 14:49:36 Info: git-lfs (/usr/bin/git-lfs): git-lfs/2.11.0 (GitHub; linux amd64; go 1.14.4)
2021/12/15 14:49:36 /usr/bin/git clone -h
2021/12/15 14:49:36 /usr/bin/git submodule -h
2021/12/15 14:49:36 /usr/bin/git clone --quiet --no-tags --single-branch --depth 1 -- https://github.com/lizzzcai/shipwright-samples.git /workspace/source
2021/12/15 14:49:37 fatal: could not read Username for 'https://github.com': terminal prompts disabled (exit code 128)

Step failed

To Reproduce
Steps to reproduce the behavior:

build a function from a private repo:

...
  build:
    builder: openfunction/builder:v1
    env:
      FUNC_NAME: "HelloWorld"
      FUNC_TYPE: "http"
    srcRepo:
      url: "https://github.com/lizzzcai/<private>.git"
      sourceSubPath: "sample-go"
    builderCredentials: 
      name: secret-git-basic-auth
...

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

I tried to use shipwright to build from private repo but failed as well. The error is a bit different from the one I show above, you can check the issue below.
It looks like an issue in shipwright 0.6.0 shipwright-io/build#955 and solved in the latest version.

Can openfunction upgrade to use 0.7.0? https://github.com/shipwright-io/build/releases/tag/v0.7.0

Add ScaleOptionTemplate and ComponentTemplate

Description
When using OpenFunction, we often create scaledobjects and scaledjobs resources of keda, as well as component resources of dapr.

If a generic template could be provided for configurations, it would be possible to reference the same configuration in multiple functions without having to do similar work for each function.

Additional context
none

้•œๅƒๆ‰พไธๅˆฐๅ•Š๏ผŒๅฅฝ็ปๆœ›

ๅฅฝๅคšๅ›ฝๅค–็š„้•œๅƒdockerhubไนŸๆ‰พไธๅˆฐ๏ผŒ็œŸ็š„ๅฎžๅœจๆ˜ฏๆ‰พไธๅˆฐ๏ผŒๅฎ˜ๆ–น่ƒฝๆŠŠ้•œๅƒๆ‰“ๅŒ…ๅˆฐๅฎ˜ๆ–น็š„openfunction ้•œๅƒไป“ๅบ“ๅ—

Updates to the event api do not trigger updates to the function(dapr components)

Description
When an event api resource, such as an EventSource resource, is updated, the corresponding dapr components are not updated.

Environmental
Tell us what your cluster environment is like, e.g.

  • Operating System Information
    Ubuntu 18.04 x86_64
  • kubernetes version
    v1.22.2+k3s2
  • OpenFunction version
    v0.4.0 and latest
  • Versions of dependent components (e.g. dapr, keda, shipwright, knative)
    dapr v1.4.0
    keda v2.4.0
    knative v0.26.0

Expected behavior
The current implementation of our Events Framework, i.e. the workload instances of EventSource and Trigger are served by the OpenFunction core api, which means that the reconcile logic of EventSource and Trigger is to generate a Function resource, which manages the dapr component docked to the event source and trigger target.
So when the configuration of the EventSource(or Trigger) changes (e.g. the address of the event source changes, the access account changes), we should expect that the corresponding dapr components will change as well.

Actual behavior
When the configuration of the EventSource(or Trigger) has changed (e.g. change of link address of the event source, change of access account), the corresponding dapr components have not changed.

To Reproduce
Steps to reproduce the behavior:

  1. Create an EventSource
  2. It can be observed that the EventSource function works properly and generates the corresponding dapr components(we can named them of version 1)
  3. Make any normal changes to the EventSource(We just want its dapr components to change)
  4. After applying this change, it can be observed that the dapr components associated with the EventSource do not change

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Suggested recommended labels for OpenFunction's components

Description

Refer to https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ to add the necessary labels to the components(deployment or pod) of OpenFunction so that it can provide efficient information to the user and can be adapted to some common queries.

For the deployment resource, I think at least the following labels need to be added:

    app.kubernetes.io/name: openfunction-controller-manager
    app.kubernetes.io/version: "v0.4.0"

[Proposal]Optimization of readme

Proposal

  • Motivation
    The current Readme document presents too much content, and I suggest that the content be optimized and triaged to highlight key information.
  • Goals
    Move references to the website and prioritize samples and user-cases for display
  • Example

# Logo or Banner

# One Sentence Introduction


# Main features or Overview

# Samples or Use cases

# Getting Started(how to install)

# Docs(link to website)

# Community(Meeting, Slack, Contributing..)

# Code of Conduct

  • Action Items
    1. Adjust readme
    2. Adjust website

Add global configuration for OpenFunction

Description
We need to add a global configuration for OpenFunction's controller-manager, such as the plugin configuration, the configuration of other components, and so on.

We can use the configMap resource to implement this feature.

Additional context
example:

apiVersion: v1
data:
  # Tell OpenFunction the namespace where knative-serving is located
  knative-serving.namespace: "knative-serving"
  # Tell OpenFunction the name of the ConfigMap of the knative-serving's configuration
  knative-serving.config-features.name: "config-features"
  # Configuration of the tracing of functions
  plugins.tracing: |
    # Switch for tracing, default to false
    enabled: false
    # Provider name can be set to "skywalking", "opentelemetry"
    # A valid provider must be set if tracing is enabled.
    provider:
      name: "skywalking"
      oapServer: "localhost:xxx"
    # Custom tags to add to tracing
    tags:
      func: function-with-tracing
      layer: faas
      tag1: value1
      tag2: value2
    baggage:
    # baggage key is `sw8-correlation` for skywalking and `baggage` for opentelemetry
    # Correlation context for skywalking: https://skywalking.apache.org/docs/main/latest/en/protocols/skywalking-cross-process-correlation-headers-protocol-v1/
    # baggage for opentelemetry: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/baggage/api.md
    # W3C Baggage Specification/: https://w3c.github.io/baggage/
      key: sw8-correlation # key should be baggage for opentelemetry
      value: "base64(string key):base64(string value),base64(string key2):base64(string value2)"
  # Configuration of the order of the plugins
  plugins: |
    pre:
    - plugin-custom
    - plugin-example
    post:
    - plugin-custom
    - plugin-example
kind: ConfigMap
metadata:
  creationTimestamp: "2022-03-06T10:46:38Z"
  labels:
    app.kubernetes.io/version: v0.5.0
  name: openfunction-config
  namespace: openfunction
  resourceVersion: "85553282"
  uid: fb6bfa6f-b50a-420a-8027-67af4bf3b395

Function ingress support

According to the proposal unified-access-entry, we will begin work on the OpenFunction function ingress capability.

This issue will be used to track the progress of the capability development and ongoing requirements gathering.

[Discussion] Add the ability to control concurrency of functions

Description
In the actual running of the function, we may need to control the concurrency of the function.

The current serving engines of OpenFunction - Knative Serving and Dapr - both have the ability to control runtime concurrency. We need to express this in the Function CRD in some concise and explicit way (annotations, properties, etc.)

Additional context
Reference:
https://knative.dev/docs/serving/autoscaling/concurrency/
https://docs.dapr.io/operations/configuration/control-concurrency/

Refactoring OpenFuncAsync runtime definition

Description
Currently, the OpenFuncAsync runtime is defined as below:

  serving:
    runtime: "OpenFuncAsync"
    openFuncAsync:
      dapr:
        inputs:
          - name: kafka
            component: kafka-receiver
            type: bindings
        outputs:
          - name: notify
            type: bindings
            component: notification-manager
            operation: "post"
        annotations:
          dapr.io/log-level: "debug"
        components:
          kafka-receiver:
            type: bindings.kafka
            version: v1
            metadata:
              - name: brokers
                value: "kafka-logs-receiver-kafka-brokers:9092"
              - name: authRequired
                value: "false"
              - name: publishTopic
                value: "logs"
              - name: topics
                value: "logs"
              - name: consumerGroup
                value: "logs-handler"
          notification-manager:
            type: bindings.http
            version: v1
            metadata:
              - name: url
                value: http://notification-manager-svc.kubesphere-monitoring-system.svc.cluster.local:19093/api/v2/alerts
      keda:
        scaledObject:
          pollingInterval: 15
          minReplicaCount: 0
          maxReplicaCount: 10
          cooldownPeriod: 30
          triggers:
            - type: kafka
              metadata:
                topic: logs
                bootstrapServers: kafka-logs-receiver-kafka-brokers.default.svc.cluster.local:9092
                consumerGroup: logs-handler
                lagThreshold: "10"

There are a few problems here:

  • The inputs and outputs is function level fields and doesn't belong to dapr
  • The dapr part is actually function binding definitions, it's better to make it clear
  • The keda part is actually function scale Options, and it's better to make it clear as well.

So maybe we can make changes like below:

  serving:
    runtime: "OpenFuncAsync"
    openFuncAsync:
      inputs:
        - name: kafka
          component: kafka-receiver
          type: bindings
      outputs:
        - name: notify
          type: bindings
          component: notification-manager
          operation: "post"
      bindings:
        dapr:
          annotations:
            dapr.io/log-level: "debug"
          components:
            kafka-receiver:
              type: bindings.kafka
              version: v1
              metadata:
                - name: brokers
                  value: "kafka-logs-receiver-kafka-brokers:9092"
                - name: authRequired
                  value: "false"
                - name: publishTopic
                  value: "logs"
                - name: topics
                  value: "logs"
                - name: consumerGroup
                  value: "logs-handler"
            notification-manager:
              type: bindings.http
              version: v1
              metadata:
                - name: url
                  value: http://notification-manager-svc.kubesphere-monitoring-system.svc.cluster.local:19093/api/v2/alerts
      scaleOptions:
        keda:
          scaledObject:
            pollingInterval: 15
            minReplicaCount: 0
            maxReplicaCount: 10
            cooldownPeriod: 30
            triggers:
              - type: kafka
                metadata:
                  topic: logs
                  bootstrapServers: kafka-logs-receiver-kafka-brokers.default.svc.cluster.local:9092
                  consumerGroup: logs-handler
                  lagThreshold: "10"

Maybe we can simply remove the dapr and keda and use bindings and scaleOptions instead?
What do you think @wanjunlei @tpiperatgod ๏ผŸ

@tpiperatgod Do we need to change functions framework and builders besides the CRD and controller changes?

Add bindings to knative sync functions

Description
Currently, OpenFuncAsync functions can not be triggered by HTTP, we need to add HTTP trigger for Async functions.

The idea is:

  1. Use Knative sync functions to receive an event in plain JSON or CloudEvent format
  2. Send the received event to a dapr output binding or pubsub component, most likely a MQ such as Kafka or NATS
  3. Trigger an async function from the MQ

So we need to add dapr output bindings or pubsub to knative sync functions like below:

  serving:
    runtime: "Knative"
    bindings:
      dapr:
        annotations:
          dapr.io/log-level: "debug"
        components:
          kafka-receiver:
            type: bindings.kafka
            version: v1
            metadata:
              - name: brokers
                value: "kafka-logs-receiver-kafka-brokers:9092"
              - name: authRequired
                value: "false"
              - name: publishTopic
                value: "logs"
              - name: topics
                value: "logs"
              - name: consumerGroup
                value: "logs-handler"
    scaleOptions:
      minReplicaCount: 1
      maxReplicaCount:  10
    knative:
      outputs:
        - name: kafka
          component: kafka-receiver
          type: bindings

Knative with dapr enabled sample can be found here: https://github.com/dapr/samples/tree/master/knative-distributed-calculator

Support to keep the builder after the build is completed

Description
Support to keep the builder after the build is completed, the user can set how many builders to keep.
Users can set the time for the builder to save and support deleting expired builders automatically.

Additional context

Questions on unified access entry and feature requests

Description
A clear and concise description of what the feature is.

Hi OpenFunction, I saw the new feature of the unified access entry was added #158. I have some queries on this feature and also have some requirements not sure if it can be supported by this feature.

  1. in the docs, the default ingress controller is nginx-ingress, is there any other ingress is supported? if yes, how to switch it and is there any example.
  2. Can user use Kubernetes gateway API ref.
  3. Can we use istio-gateway as the unified access entry (link to point 1)? As service mesh is very popular and it will be good to support it (similar to knative)
  4. Is OpenFunction planning to has its own gateway? Similar to Kourier

For the feature requests, I have the follow user story and want to discuss if OpenFunction can support it by the current unified access entry or in the future.

Host-based routing and path-based routing

We have deployed some services.
for example, we have the following namespaces:

user1-ns1
user1-ns2
above are two namespaces but they are belonging to the same user (user1, so the services are crossing multiple namespaces).

within each namespace, we have two servings, service1 and service 2.

In current host-based routing, we have the following deployment URLs:

service1.user1-ns1.example.com
service2.user1-ns1.example.com
service1.user1-ns2.example.com
service2.user1-ns2.example.com

What we expect is a path-based routing like the following:

api.example.com/user1-ns1/service1
api.example.com/user1-ns1/service2
api.example.com/user1-ns2/service1
api.example.com/user1-ns2/service2

or
user1-ns1.example.com/service1
user1-ns2.example.com/service1

etc.

You can find the details of this in this thread: knative/serving#11997 (comment). Knative support host based routing but currently not support path-based routing.
I hope that OpenFunction can support both as it is a demanding feature (can find it from the thread as well).

domainTemplate to easily define host-based/path-based routing

Ref:domainTemplate

domainTemplate: {{` "{{.Name}}-{{.Namespace}}.{{.Domain}}" `}}
pathBasedRoutingEnabled: True
pathTemplate: {{` "api.{{.Domain}}/{{.Namespace}}/{{.Name}}" `}} # user need to avoid conflict of the path by themselves.

Provide an easy way for user to config their custom domain.

DomainMapping to support multi domain
DomainMapping. It is a very interesting feature especially in multi-tenancy use case.

Personally I hope OpenFunction can support gateway that are popular in the market and has a central place to config it easily (similar to how the Knative is configured)

Additional context
NA

Function compilation sources add object storage, etc.

Description
Can openfunction add a feature ๏ผŸ
1ใ€Get the source code from the object store or some store url for compilation.
2ใ€Get binary files from object storage for image building.

Additional context
image

Make deploy.sh and delete.sh run properly on MacOS

I notice that getopt is used in both deploy.sh and delete.sh, but macOS does not support this command by default.
Can we use another solution to replace getopt? Such as this:

while test $# -gt 0
do
  _key="$1"
  case "$_key" in
    --all)
      all=true
      shift
      ;;
    --with-shipwright)
      with_shipwright=true
      shift
      ;;
    --with-knative)
      with_knative=true
      shift
      ;;
    --with-openFuncAsync)
      with_openFuncAsync=true
      shift
      ;;
    -p | --poor-network)
      poor_network=true
      shift
      ;;
    *)
      echo "Internal error!"
      exit 1
      ;;
  esac
  shift
done

Request to support compiling and installing OpenFunction (CLI) on ARM64

Description
A clear and concise description of what the feature is.

Support compiling and installing OpenFunction (CLI) on ARM64

Additional context

Add any other context or screenshots about the feature request here.

@lucj compiled for darwin arm64 from the source and got the following error when Luc tried to install the framework and all its dependencies on Mac M1.

./ofn_darwin_arm64 install --all
Start installing OpenFunction and its dependencies.
The following components will be installed:
+------------------+---------+
| COMPONENT        | VERSION |
+------------------+---------+
| Tekton Pipelines | 0.30.0  |
| Shipwright       | 0.6.1   |
| Kourier          | 1.0.1   |
| CertManager      | 1.5.4   |
| OpenFunction     | 0.5.0   |
| Keda             | 2.4.0   |
| IngressNginx     | 1.1.0   |
| Dapr             | 1.5.1   |
| Knative Serving  | 1.0.1   |
| DefaultDomain    | 1.0.1   |
+------------------+---------+
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x38 pc=0x101424b58]

goroutine 1 [running]:
github.com/OpenFunction/cli/pkg/components/common.(*Operator).GetInventoryRecord(0x140003509b0, {0x1019e7828, 0x14000331740}, 0x0)
	/Users/luc/Desktop/cli-0.5.2/pkg/components/common/common.go:83 +0x28
github.com/OpenFunction/cli/pkg/cmd/subcommand.(*Install).RunInstall(0x14000495f80, 0x140004ac2c0, 0x140004a6a00)
	/Users/luc/Desktop/cli-0.5.2/pkg/cmd/subcommand/install.go:247 +0x3bc
github.com/OpenFunction/cli/pkg/cmd/subcommand.NewCmdInstall.func2(0x140004a6a00, {0x14000489460, 0x0, 0x1})
	/Users/luc/Desktop/cli-0.5.2/pkg/cmd/subcommand/install.go:99 +0x88
github.com/spf13/cobra.(*Command).execute(0x140004a6a00, {0x14000489450, 0x1, 0x1})
	/Users/luc/go/pkg/mod/github.com/spf13/[email protected]/command.go:860 +0x640
github.com/spf13/cobra.(*Command).ExecuteC(0x14000467400)
	/Users/luc/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x410
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/luc/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
main.main()
	/Users/luc/Desktop/cli-0.5.2/cmd/main.go:9 +0x7c

We open this issue to track if others have the same user requests on the compiling and installing OpenFunction (CLI) on ARM64.

OpenFunction website Initiation

After we discussed the website initiation in our community call, we are going to use a Hugo template Docsy to build the OpenFunction website from scratch.

Proposed steps:

  1. Create a new GitHub repo for this website in OpenFunction Org.
  2. Initiate the website framework.
  3. Make it accessible, we can preview it locally or access it from the internet.
  4. Adjust the style and design to be aligned with the OpenFunction.
  5. Migrate the content to the website.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.