Giter Club home page Giter Club logo

openfunction's Introduction

Overview

OpenFunction is a cloud-native open source FaaS (Function as a Service) platform aiming to enable users to focus on their business logic without worrying about the underlying runtime environment and infrastructure. Users only need to submit business-related source code in the form of functions.

OpenFunction features but not limited to the following:

  • Convert business-related function source code to runnable application source code.
  • Generate a deployable container image from the converted application source code.
  • Deploy the generated container image to the underlying runtime environment such as K8s, and automatically scale up and down according to business traffic, and scale to 0 when there is no traffic.
  • Provide event management functions for trigger functions.
  • Provide additional functions to manage function versions, ingress management etc.

CustomResourceDefinitions

Events CRDs

OpenFunction provides an event handling framework called OpenFunction events that complements the event-driven capabilities of OpenFunction as a FaaS framework.

You can refer to OpenFunction Events Framework Concepts for more information.

Core CRDs

The core capability of OpenFunction is to enable users to develop, run and manage applications as executable function code. OpenFunction implements the following custom resource definitions (CRDs):

  • Function, defines a function.
  • Builder, defines a function builder.
  • Serving, defines a function workload.
  • Domain, defines a unified entry point for sync functions.

Function

The goal of Function is to control the lifecycle management from user code to the final application that can respond to events through a single profile.

Function manages and coordinates Builder and Serving resources to handle the details of the process.

Builder

The goal of Builder is to compile the user's function source code into an application image.

It will fetch the code from the code repository, build the application image locally and publish it to the container image repository.

Currently, OpenFunction Builder uses Shipwright and Cloud Native Buildpacks to build container images.

Shipwright and Cloud Native Buildpacks

Shipwright is an extensible framework for building container images on Kubernetes.

Cloud Native Buildpacks is an OCI standard image building framework that transforms your application source code into container images without a Dockerfile.

OpenFunction Builder controls the build process of application images by Shipwright, including fetching code, building and publishing images via Cloud Native Buildpacks.

Serving

The goal of Serving is to run functions in a highly elastic manner (dynamically scale 0 <-> N).

Currently, OpenFunction supports two serving runtimes, Knative and OpenFuncAsync. At least one of these runtimes is required.

Knative

Knative Serving builds on Kubernetes to support deploying and serving serverless applications and functions. Knative Serving is easy to get started with and scales to support advanced scenarios.

OpenFuncAsync

OpenFuncAsync is an event-driven Serving runtime. It is implemented based on KEDA + Dapr.

You can refer to Prerequisites and use --with-openFuncAsync to install OpenFuncAsync runtime.

The OpenFuncAsync functions can be triggered by various event types, such as MQ, cronjob, DB events, etc. In a Kubernetes cluster, OpenFuncAsync functions run in the form of deployments or jobs.

Domain

Domain defines a unified entry point for sync functions using ingress, user can use

http://<domain-name>.<domain-namespace>/<function-namespace>/<function-name>

to access a function.

Only one Domain can be defined in a cluster. A Domain requires a Ingress Controller. By default, we use nginx-ingress. You can refer to Prerequisites and use --with-ingress to install it, or install it manually. If the nginx-ingress does not use the default namespace and name, please modify the config/domain/default-domain.yaml, and run

make manifests

to update the config/bundle.yaml, and use this file to deploy openFunction.

Compatibility

Kubernetes compatibility matrix

The following versions are supported and work as we test against these versions in their respective branches. But note that other versions might work!

OpenFunction Kubernetes 1.19 Kubernetes 1.20 Kubernetes 1.21 Kubernetes 1.22
release-0.3
release-0.4 ×
HEAD ×

QuickStart

Prerequisites

The current version of OpenFunction requires that you have a Kubernetes cluster with version >=1.18.6.

In addition, you need to deploy several dependencies for the OpenFunction Builder and Serving.

You can use the following command to setup OpenFunction Builder and Serving:

sh hack/deploy.sh --all

This command will install dependencies of all supported Builder and Serving to your cluster.

You can also customize the installation with the following parameters:

Parameter Comment
--all Install all supported Builder and Serving
--with-shipwright Install Shipwright builder
--with-knative Install Knative serving runtime
--with-openFuncAsync Install OpenFuncAsync serving runtime
--with-ingress Install nginx-ingress
--region-cn Use this if you have poor network connectivity to GitHub/Googleapis

Install OpenFunction

You can install the OpenFunction platform by the following command:

  • Install the latest stable version
kubectl create -f https://github.com/OpenFunction/OpenFunction/releases/download/v0.4.0/bundle.yaml
  • Install the development version
kubectl create -f https://raw.githubusercontent.com/OpenFunction/OpenFunction/main/config/bundle.yaml

Note: When using non-default namespaces, make sure that the ClusterRoleBinding in the namespace is adapted.

Verify the installation

kubectl get pods --namespace openfunction

NAME                                               READY   STATUS    RESTARTS   AGE
openfunction-controller-manager-6955498c9b-hjql7   2/2     Running   0         2m2s

Sample: Run a function.

If you have already installed the OpenFunction platform, refer to OpenFunction samples to find more samples.

Here is an example of a sync function.

This function will write "Hello, World!" to the HTTP response.

package hello

import (
	"net/http"
	"fmt"
)

func HelloWorld(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, "Hello, World!\n")
}

And an async function example.

This function will receive a greeting message and then send it to "another-target".

package bindings

import (
	"encoding/json"
	"log"
  
	ofctx "github.com/OpenFunction/functions-framework-go/openfunction-context"
)

func BindingsOutput(ctx *ofctx.OpenFunctionContext, in []byte) int {
	log.Printf("receive greeting: %s", string(in))
	_ := ctx.SendTo(in, "another-target")
	return 200
}

Uninstall OpenFunction

  • Uninstall the latest stable version
kubectl delete -f https://raw.githubusercontent.com/OpenFunction/OpenFunction/release-0.4/config/bundle.yaml
  • Uninstall the development version
kubectl delete -f https://raw.githubusercontent.com/OpenFunction/OpenFunction/main/config/bundle.yaml

Development

You can get help on developing this project by visiting Development Guide.

Roadmap

Here you can find OpenFunction's roadmap.

Community

Community Call

Meeting Info: Zoom

Meeting Time: Wednesday at 15:30~16:30 Beijing Time (biweekly, starting from June 23rd, 2021) Meeting Calendar

Meeting notes

Contact Us

openfunction's People

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.