Refunc is a Kubernetes native serverless platform.
- Easy of use - Embrace the serverless ecosystem with an AWS Lambda compatible API and runtimes
- Portable - Run everywhere that has Kubernetes
- Scale from zero - Autoscale from zero-to-many and vice versa
- Extensible - Runtime compatibility layer (lambda and other clouds' function), transport layer (NATS based for now)
Before starting, you need a Kubernetes cluster. You can use minikube to run a minimal Kubernetes cluster locally.
If you'd like to run on macOS, Docker for Mac with Kubernetes enabled is recommended.
refunc-play, a minimal setup of Refunc, using the following commands:
# This will create namespace `refunc-play` and deploy components in it docker run --rm -it refunc/refunc refunc play gen -n refunc-play | kubectl apply -f - # create runtime python3.7 kubectl create -n refunc-play -f \ https://github.com/refunc/lambda-python3.7-example/releases/download/v0.0.2/xenv.yaml
The AWS Way
Refunc uses an AWS API compatible gateway to provide Lambda and S3 services, which makes it possible to use the AWS CLI to manage functions locally.
Before starting, we need to forward the gateway to your localhost:
kubectl port-forward deployment/aws-api-gw 9000:80 -n refunc-play
Download the pre-built function for convenience:
cd /tmp wget https://github.com/refunc/lambda-python3.7-example/releases/download/v0.0.1/lambda.zip
aws --endpoint-url=http://127.0.0.1:9000 \ lambda create-function --function-name localtest \ --handler lambda_function.lambda_handler \ --zip-file fileb:///tmp/lambda.zip \ --runtime python3.7 \ --role arn:aws:iam::XXXXXXXXXXXXX:role/your_lambda_execution_role
aws --endpoint-url=http://127.0.0.1:9000 \ lambda invoke --function-name localtest /tmp/output.json && cat /tmp/output.json
The Refunc Way
Let's create a Lambda function using the python3.7 runtime with an HTTP endpoint:
kubectl create -n refunc-play -f https://github.com/refunc/lambda-python3.7-example/releases/download/v0.0.2/inone.yaml
Forward the Refunc HTTP gateway to your localhost:
kubectl port-forward deployment/refunc-play 7788:7788 -n refunc-play
Now, it's OK to send a request to your function:
curl -v http://127.0.0.1:7788/refunc-play/python37-function
Copyright (c) 2018 refunc.io
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.