1
+ GIT_SHA1 ?= master
2
+ BASE_URL := https://raw.githubusercontent.com/kubeless/runtimes/$(GIT_SHA1 )
1
3
2
- build2.7 :
3
- docker build --pull --no-cache -t kubeless/python:2.7$$ RUNTIME_TAG_MODIFIER -f Dockerfile.2.7 .
4
+ # Wait until the Pod is in ready state. Without a readinessProbe it is not possible to
5
+ # tell exactly when the Pod is ready to accept requests. So, adding additional sleep
6
+ # (default = 2 seconds).
7
+ define rollout-status
8
+ kubectl rollout status deployment/$(patsubst % -verify,% ,$1) && sleep $(if $2,$2,2)
9
+ endef
4
10
5
11
build3.6 :
6
12
docker build --pull --no-cache -t kubeless/python:3.6$$ RUNTIME_TAG_MODIFIER -f Dockerfile.3.6 .
7
13
8
14
build3.7 :
9
15
docker build --pull --no-cache -t kubeless/python:3.7$$ RUNTIME_TAG_MODIFIER -f Dockerfile.3.7 .
10
16
11
- push2.7 :
12
- docker push kubeless/python:2.7$$ RUNTIME_TAG_MODIFIER
13
-
14
17
push3.6 :
15
18
docker push kubeless/python:3.6$$ RUNTIME_TAG_MODIFIER
16
19
17
20
push3.7 :
18
21
docker push kubeless/python:3.7$$ RUNTIME_TAG_MODIFIER
19
22
20
23
# Mandatory jobs
21
- build-all : build2.7 build3.6 build3.7
22
- push-all : push2.7 push3.6 push3.7
24
+ build-all : build3.6 build3.7
25
+ push-all : push3.6 push3.7
23
26
24
27
# Testing jobs
25
- deploy : get-python get-python-deps get-python-custom-port get-python-36 get-python-37 get-python-url-deps scheduled-get-python timeout-python get-python-secrets post-python post-python-custom-port custom-get-python
26
- test : get-python-verify get-python-deps-verify get-python-custom-port-verify get-python-36-verify get-python-37-verify get-python-url-deps-verify scheduled-get-python-verify timeout-python-verify get-python-secrets-verify custom-get-python-verify post-python-verify post-python-custom-port-verify
27
-
28
- get-python :
29
- kubeless function deploy get-python --runtime python2.7 --handler helloget.foo --from-file examples/helloget.py
30
-
31
- get-python-verify :
32
- kubectl rollout status deployment/get-python && sleep 2
33
- kubeless function call get-python | egrep hello.world
34
- kubeless function top --function get-python --out yaml | egrep total_calls.* [1-100000]
28
+ deploy : get-python-deps get-python-custom-port get-python-36 get-python-37 get-python-url-deps scheduled-get-python timeout-python get-python-secrets post-python post-python-custom-port custom-get-python python-preload
29
+ test : get-python-deps-verify get-python-custom-port-verify get-python-36-verify get-python-37-verify get-python-url-deps-verify scheduled-get-python-verify timeout-python-verify get-python-secrets-verify custom-get-python-verify post-python-verify post-python-custom-port-verify python-preload-verify
35
30
36
31
get-python-deps :
37
- cd examples && zip hellowithdeps.zip hellowithdeps.py hellowithdepshelper.py && cd ..
38
- kubeless function deploy get-python-deps --runtime python2.7 --handler hellowithdeps.foo --from-file examples/hellowithdeps.zip --dependencies examples/requirements.txt
32
+ cd examples && zip hellowithdeps.zip hellowithdeps.py hellowithdepshelper.py
33
+ kubeless function deploy get-python-deps --runtime python3.6 --handler hellowithdeps.foo --from-file examples/hellowithdeps.zip --dependencies examples/requirements.txt
39
34
40
35
get-python-deps-verify :
41
- kubectl rollout status deployment/get-python-deps && sleep 2
36
+ $( call rollout-status, $@ ,5)
42
37
kubeless function call get-python-deps | egrep Google
43
38
44
39
get-python-custom-port :
45
- kubeless function deploy get-python-custom-port --runtime python2.7 --handler helloget.foo --from-file examples/helloget.py --port 8081
40
+ kubeless function deploy get-python-custom-port --runtime python3.6 --handler helloget.foo --from-file examples/helloget.py --port 8081
46
41
47
42
get-python-custom-port-verify :
48
- kubectl rollout status deployment/get-python-custom-port && sleep 2
43
+ $( call rollout-status, $@ )
49
44
kubectl get svc get-python-custom-port -o yaml | grep ' targetPort: 8081'
50
45
kubeless function call get-python-custom-port | egrep hello.world
51
46
52
47
get-python-36 :
53
48
kubeless function deploy get-python-36 --runtime python3.6 --handler helloget.foo --from-file examples/helloget.py
54
49
55
50
get-python-36-verify :
56
- kubectl rollout status deployment/get-python-36 && sleep 2
51
+ $( call rollout-status, $@ )
57
52
kubeless function call get-python-36 | egrep hello.world
58
53
59
54
get-python-37 :
60
55
kubeless function deploy get-python-37 --runtime python3.7 --handler helloget.foo --from-file examples/helloget.py
61
56
62
57
get-python-37-verify :
63
- kubectl rollout status deployment/get-python-37 && sleep 2
58
+ $( call rollout-status, $@ )
64
59
kubeless function call get-python-37 | egrep hello.world
65
60
66
61
get-python-url-deps :
67
- kubeless function deploy get-python-url-deps --runtime python2.7 --handler helloget.foo --from-file https://raw.githubusercontent.com/kubeless/kubeless/v1.0.0-alpha.1/examples/python/hellowithdeps.py --dependencies https://raw.githubusercontent.com/kubeless/kubeless/v1.0.0-alpha.1/examples/python/requirements.txt
62
+ cd examples && zip hellowithdeps.zip hellowithdeps.py hellowithdepshelper.py
63
+ kubeless function deploy get-python-url-deps --runtime python3.6 --handler hellowithdeps.foo --from-file examples/hellowithdeps.zip --dependencies $( BASE_URL) /stable/python/examples/requirements.txt
68
64
69
65
get-python-url-deps-verify :
70
- kubectl rollout status deployment/get-python-url-deps && sleep 2
66
+ $( call rollout-status, $@ )
71
67
kubeless function call get-python-url-deps | egrep Google
72
68
73
69
scheduled-get-python :
74
- kubeless function deploy scheduled-get-python --schedule " * * * * *" --runtime python2.7 --handler helloget.foo --from-file examples/helloget.py
70
+ kubeless function deploy scheduled-get-python --schedule " * * * * *" --runtime python3.6 --handler helloget.foo --from-file examples/helloget.py
75
71
76
72
scheduled-get-python-verify :
77
73
number=" 1" ; \
@@ -92,35 +88,35 @@ scheduled-get-python-verify:
92
88
timeout-python :
93
89
$(eval TMPDIR := $(shell mktemp -d) )
94
90
printf ' def foo(event, context):\n%4swhile 1: pass\n%4sreturn "hello world"\n' > $(TMPDIR ) /hello-loop.py
95
- kubeless function deploy timeout-python --runtime python2.7 --handler helloget.foo --from-file $( TMPDIR) /hello-loop.py --timeout 3
91
+ kubeless function deploy timeout-python --runtime python3.6 --handler helloget.foo --from-file $( TMPDIR) /hello-loop.py --timeout 3
96
92
rm -rf $(TMPDIR )
97
93
98
94
timeout-python-verify :
99
- kubectl rollout status deployment/timeout-python && sleep 2
95
+ $( call rollout-status, $@ )
100
96
$(eval MSG := $(shell kubeless function call timeout-python 2>&1 || true) )
101
97
echo $(MSG ) | egrep Request.timeout.exceeded
102
98
103
99
get-python-secrets :
104
100
kubectl create secret generic test-secret --from-literal=key=MY_KEY || true
105
- kubeless function deploy get-python-secrets --runtime python2.7 --handler helloget.foo --from-file examples/helloget.py --secrets test-secret
101
+ kubeless function deploy get-python-secrets --runtime python3.6 --handler helloget.foo --from-file examples/helloget.py --secrets test-secret
106
102
107
103
get-python-secrets-verify :
108
- kubectl rollout status deployment/get-python-secrets && sleep 2
104
+ $( call rollout-status, $@ )
109
105
$(eval pod := $(shell kubectl get pod -l function=get-python-secrets -o go-template -o custom-columns=:metadata.name --no-headers=true) )
110
106
kubectl exec -it $(pod ) cat /test-secret/key | egrep " MY_KEY"
111
107
112
108
custom-get-python :
113
109
kubeless function deploy --runtime-image kubeless/get-python-example@sha256:6a14400f14e26d46a971445b7a850af533fe40cb75a67297283bdf536e09ca5e custom-get-python
114
110
115
111
custom-get-python-verify :
116
- kubectl rollout status deployment/custom-get-python && sleep 2
112
+ $( call rollout-status, $@ )
117
113
kubeless function call custom-get-python | egrep hello.world
118
114
119
115
post-python :
120
- kubeless function deploy post-python --runtime python2.7 --handler hellowithdata.handler --from-file examples/hellowithdata.py
116
+ kubeless function deploy post-python --runtime python3.6 --handler hellowithdata.handler --from-file examples/hellowithdata.py
121
117
122
118
post-python-verify :
123
- kubectl rollout status deployment/post-python && sleep 2
119
+ $( call rollout-status, $@ )
124
120
kubeless function call post-python --data ' {"it-s": "alive"}' | egrep " it.*alive"
125
121
# Verify event context
126
122
logs=` kubectl logs --tail=1000 -l function=post-python` ; \
@@ -131,9 +127,17 @@ post-python-verify:
131
127
echo $$ logs | grep -q " event-id.*"
132
128
133
129
post-python-custom-port :
134
- kubeless function deploy post-python-custom-port --runtime python2.7 --handler hellowithdata.handler --from-file examples/hellowithdata.py --port 8081
130
+ kubeless function deploy post-python-custom-port --runtime python3.6 --handler hellowithdata.handler --from-file examples/hellowithdata.py --port 8081
135
131
136
132
post-python-custom-port-verify :
137
- kubectl rollout status deployment/post-python-custom-port && sleep 2
133
+ $( call rollout-status, $@ )
138
134
kubectl get svc post-python-custom-port -o yaml | grep ' targetPort: 8081'
139
135
kubeless function call post-python-custom-port --data ' {"it-s": "alive"}' | egrep " it.*alive"
136
+
137
+ python-preload :
138
+ cd examples && zip preload.zip preload.py preloadhelper.py
139
+ kubeless function deploy python-preload --runtime python3.6 --handler preload.handler --from-file examples/preload.zip --timeout 3
140
+
141
+ python-preload-verify :
142
+ $(call rollout-status,$@ ,10)
143
+ kubeless function call python-preload | egrep hello.world
0 commit comments