Skip to content

Commit dec4a5f

Browse files
committed
[+] Add res files
1 parent 3d9eb16 commit dec4a5f

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
11
# lambda-python3.7-example
2+
23
Example of lambda 3.7 runtime and function
4+
5+
[lambda_function.py](./lambda_function.py) was copied from [lambci/examples/python/lambda_function.py](https://github.com/lambci/docker-lambda/blob/113c2ddd26f39cab2ce814197705df90713e32cf/examples/python/lambda_function.py)
6+
7+
## Quick start
8+
9+
### Ensure refunc is installed
10+
11+
for playing in dev cluster (eg. minikube), install mini refunc in refunc-play namespace
12+
13+
```shell
14+
docker run --rm -it -e REFUNC_ENV=cluster refunc/refunc refunc play gen -n refunc-play | kubectl apply -f - && kubectl get all -n refunc-play
15+
```
16+
17+
### Create Xenv and function
18+
19+
```shell
20+
kubectl create -f . -n refunc-play
21+
```

function.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: k8s.refunc.io/v1beta3
2+
kind: Funcdef
3+
metadata:
4+
name: python37-function
5+
spec:
6+
body: https://github.com/refunc/lambda-python3.7-example/releases/download/v0.0.1/lambda.zip
7+
entry: lambda_function.lambda_handler
8+
hash: 553c10515b3d7abf77519eada39c744fb091fc82
9+
maxReplicas: 1
10+
runtime:
11+
name: python37
12+
timeout: 30

lambda_function.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from __future__ import print_function
2+
import os
3+
import sys
4+
import subprocess
5+
6+
# Just a test lambda, run with:
7+
# docker run --rm -v "$PWD":/var/task lambci/lambda:python2.7
8+
# OR
9+
# docker run --rm -v "$PWD":/var/task lambci/lambda:python3.6
10+
# OR
11+
# docker run --rm -v "$PWD":/var/task lambci/lambda:python3.7 lambda_function.lambda_handler
12+
13+
def lambda_handler(event, context):
14+
context.log('Hello!')
15+
context.log('Hmmm, does not add newlines in 3.7?')
16+
context.log('\n')
17+
18+
print(sys.executable)
19+
print(sys.argv)
20+
print(os.getcwd())
21+
print(__file__)
22+
print(os.environ)
23+
print(context.__dict__)
24+
25+
return {
26+
"executable": str(sys.executable),
27+
"sys.argv": str(sys.argv),
28+
"os.getcwd": str(os.getcwd()),
29+
"__file__": str(__file__),
30+
"os.environ": str(os.environ),
31+
"context.__dict__": str(context.__dict__),
32+
"ps aux": str(subprocess.check_output(['ps', 'aux'])),
33+
"event": event
34+
}
35+

xenv.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: k8s.refunc.io/v1beta3
2+
kind: Xenv
3+
metadata:
4+
name: python37
5+
spec:
6+
type: lambda
7+
transport: nats
8+
poolSize: 1
9+
container:
10+
image: lambci/lambda:python3.7
11+
imagePullPolicy: IfNotPresent

0 commit comments

Comments
 (0)