Quick Start

Before start, you need a k8s runs on somewhere, minikube is pretty enough, Docker for Mac with kubernetes enabled is recommended if your'd like to try on macOS.

Install Refunc

Install Refunc play(which is a mini setup of refunc) using the following commands:

docker run --rm -it -e REFUNC_ENV=cluster refunc/refunc \
refunc play gen -n refunc-play | kubectl apply -f -

This will create namespace refunc-play and deploy components in it.

Install runtime python3.7

kubectl create -n refunc-play -f \
https://github.com/refunc/lambda-python3.7-example/releases/download/v0.0.2/xenv.yaml

TIP

Refunc supports AWS provided runtime natively, and other converted AWS language runtimes

Moreover, new runtimes can be easily by leverage refunc as a framework, learn more

Play with function

The AWS way

Forwarding refunc http gw to local in a seperate terminal:

kubectl port-forward deployment/aws-api-gw 9000:80 -n refunc-play

Download prebuild Function for convenience

cd /tmp
wget https://github.com/refunc/lambda-python3.7-example/releases/download/v0.0.1/lambda.zip

Create python3.7 funtion

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

Invoke

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 runtime python3.7 with a http trigger:

kubectl create -n refunc-play -f https://github.com/refunc/lambda-python3.7-example/releases/download/v0.0.2/inone.yaml

Forwarding refunc http gw to local:

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

User interface

Internally we use Rancher to build our PaaS and other internal services, and currently there is a simple management UI forked from rancher/ui which is backed with our Rancher API compatible server

functions.png

Last Updated: 12/26/2018, 12:58:33 PM