Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit c99a9cd

Browse files
tzununbekovsebgoa
authored andcommitted
Buildtemplates replaced with Tekton Tasks (#34)
* Knative Build manifests replaced with Tekton Tasks, #33 * Readme and filenames updated, #33
1 parent 444d153 commit c99a9cd

File tree

8 files changed

+153
-149
lines changed

8 files changed

+153
-149
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
![TriggerMesh Knative Lambda Runtime](./triggermeshklr.png "TriggerMesh Knative Lambda Runtime")
22

3-
Knative Lambda Runtimes (e.g KLR, pronounced _clear_) are Knative [build templates](https://github.com/knative/build-templates) that can be used to run an AWS Lambda function in a Kubernetes cluster installed with Knative.
3+
Knative Lambda Runtimes (e.g KLR, pronounced _clear_) are Tekton [Tasks](https://github.com/tektoncd/pipeline/blob/master/docs/tasks.md) that can be used to run an AWS Lambda function in a Kubernetes cluster installed with Knative.
44

55
The execution environment where the AWS Lambda function runs is a clone of the AWS Lambda cloud environment thanks to a custom [AWS runtime interface](https://github.com/triggermesh/aws-custom-runtime) and some inspiration from the [LambCI](https://github.com/lambci/docker-lambda) project.
66

77
With these templates, you can run your AWS Lambda functions **as is** in a Knative powered Kubernetes cluster.
88

9-
The examples below use the [tm](https://github.com/triggermesh/tm/releases/latest) CLI to interact with Knative but one could also use `kubectl`:
9+
The examples below use the [tm](https://github.com/triggermesh/tm/releases/latest) CLI to interact with Knative but one could also use `kubectl`.
1010

1111
### Docker registry for builds
1212

@@ -36,10 +36,10 @@ NOTE: all examples below work with [Local Registry](https://github.com/triggerme
3636

3737
#### Python
3838

39-
1. Install buildtemplate
39+
1. Install runtime
4040

4141
```
42-
tm deploy buildtemplate -f https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/python-3.7/buildtemplate.yaml
42+
tm deploy task -f https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/python-3.7/runtime.yaml
4343
```
4444

4545
2. Deploy [function](https://github.com/serverless/examples/tree/master/aws-python-simple-http-endpoint)
@@ -66,10 +66,10 @@ To use Python 2.7 runtime simply replace version tag in step 1 and 2 with `pytho
6666

6767
#### Nodejs
6868

69-
1. Install node 4.3 buildtemplate
69+
1. Install node 4.3 runtime
7070

7171
```
72-
tm deploy buildtemplate -f https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/node-4.x/buildtemplate.yaml
72+
tm deploy task -f https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/node-4.x/runtime.yaml
7373
```
7474

7575
2. Deploy example function
@@ -111,10 +111,10 @@ EOF
111111
node -e "require('./handler').sayHelloAsync({}).then(h => console.log(h))"
112112
```
113113

114-
2. Install node-10.x buildtemplate
114+
2. Install node-10.x runtime
115115

116116
```
117-
tm deploy buildtemplate -f https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/node-10.x/buildtemplate.yaml
117+
tm deploy task -f https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/node-10.x/runtime.yaml
118118
```
119119

120120
3. Deploy function
@@ -169,10 +169,10 @@ func main() {
169169
}
170170
```
171171

172-
2. Install Go buildtemplate
172+
2. Install Go runtime
173173

174174
```
175-
tm deploy buildtemplate -f https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/go-1.x/buildtemplate.yaml
175+
tm deploy task -f https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/go-1.x/runtime.yaml
176176
```
177177

178178
3. Deploy function
@@ -200,10 +200,10 @@ where `~/.ssh/id_rsa` is a path to SSH private key associated with your git acco
200200

201201
#### Ruby
202202

203-
1. Install Ruby 2.5 buildtemplate
203+
1. Install Ruby 2.5 runtime
204204

205205
```
206-
tm deploy buildtemplate -f https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/ruby-2.5/buildtemplate.yaml
206+
tm deploy task -f https://raw.githubusercontent.com/triggermesh/knative-lambda-runtime/master/ruby-2.5/runtime.yaml
207207
```
208208

209209
2. Deploy example function

go-1.x/buildtemplate.yaml renamed to go-1.x/runtime.yaml

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018 TriggerMesh, Inc
1+
# Copyright 2019 TriggerMesh, Inc
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,32 +12,34 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
apiVersion: build.knative.dev/v1alpha1
16-
kind: BuildTemplate
15+
apiVersion: tekton.dev/v1alpha1
16+
kind: Task
1717
metadata:
1818
name: knative-go-runtime
1919
spec:
20-
parameters:
21-
- name: IMAGE
22-
description: The URI of the image to push, including registry host
23-
- name: TAG
24-
description: Tag of the image being pushed
25-
default: "latest"
26-
- name: DIRECTORY
27-
description: The subdirectory of the workspace/repo
28-
default: ""
29-
- name: SSH_KEY
30-
description: Name of ssh key file to authenticate in private git repository
31-
default: "git-ssh-key"
20+
inputs:
21+
params:
22+
- name: IMAGE
23+
description: Where to store resulting image
24+
- name: SSH_KEY
25+
description: SSH key
26+
default: "placeholder"
27+
- name: DIRECTORY
28+
description: The subdirectory of the workspace/repo
29+
default: "."
30+
resources:
31+
- name: sources
32+
targetPath: /workspace
33+
type: git
3234
steps:
3335
- name: dockerfile
34-
image: gcr.io/kaniko-project/executor@sha256:30ba460a034a8051b3222a32e20cb6049741e58384e3adf8c8987c004e2f2ab9
36+
image: gcr.io/kaniko-project/executor:debug-v0.8.0
3537
command:
3638
- /busybox/sh
3739
args:
3840
- -c
3941
- |
40-
cd /workspace/${DIRECTORY}
42+
cd /workspace/workspace
4143
cat <<EOF > Dockerfile
4244
FROM golang:alpine
4345
# Skip known public key check to be able to pull from private repositories
@@ -46,35 +48,31 @@ spec:
4648
&& go get github.com/triggermesh/aws-custom-runtime \
4749
&& go get github.com/triggermesh/knative-lambda-runtime/go-1.x \
4850
&& go get github.com/golang/dep/...
49-
5051
WORKDIR /go/src/handler
5152
COPY . .
52-
RUN if [ -f "$HOME/.ssh/id_${SSH_KEY}" ]; then \
53+
RUN if [ -f "$HOME/.ssh/id_${inputs.params.SSH_KEY}" ]; then \
5354
eval "\$(ssh-agent -s)"; \
54-
ssh-add $HOME/.ssh/id_${SSH_KEY}; \
55+
ssh-add $HOME/.ssh/id_${inputs.params.SSH_KEY}; \
5556
fi \
5657
&& if [ -f "Gopkg.toml" ]; then dep ensure; fi \
5758
&& go get -v \
5859
&& go install
5960
6061
FROM alpine
6162
WORKDIR /opt
62-
6363
ENV LAMBDA_TASK_ROOT "/opt"
6464
ENV _HANDLER "handler"
65-
6665
COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
6766
COPY --from=0 /go/bin/go-1.x /opt/bootstrap
6867
COPY --from=0 /go/bin/ /opt
69-
7068
ENTRYPOINT ["/opt/aws-custom-runtime"]
7169
EOF
7270
- name: export
73-
image: gcr.io/kaniko-project/executor@sha256:30ba460a034a8051b3222a32e20cb6049741e58384e3adf8c8987c004e2f2ab9
71+
image: gcr.io/kaniko-project/executor:debug-v0.8.0
7472
args:
75-
- --context=/workspace/${DIRECTORY}
76-
- --dockerfile=/workspace/${DIRECTORY}/Dockerfile
77-
- --destination=${IMAGE}:${TAG}
73+
- --context=/workspace/workspace
74+
- --dockerfile=Dockerfile
75+
- --destination=${inputs.params.IMAGE}
7876
# Workaround not to use default config which requires gcloud credentials
7977
# to pull base image from public gcr registry
8078
# https://groups.google.com/d/msg/kaniko-users/r5yoP_Ejm_c/ExoEXksDBAAJ

node-10.x/buildtemplate.yaml renamed to node-10.x/runtime.yaml

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018 TriggerMesh, Inc
1+
# Copyright 2019 TriggerMesh, Inc
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,45 +12,47 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
apiVersion: build.knative.dev/v1alpha1
16-
kind: BuildTemplate
15+
apiVersion: tekton.dev/v1alpha1
16+
kind: Task
1717
metadata:
1818
name: knative-node10-runtime
1919
spec:
20-
parameters:
21-
- name: IMAGE
22-
description: The URI of the image to push, including registry host
23-
- name: TAG
24-
description: Tag of the image being pushed
25-
default: latest
26-
- name: DIRECTORY
27-
description: The subdirectory of the workspace/repo
28-
default: ""
29-
- name: HANDLER
30-
default: "function.handler"
20+
inputs:
21+
params:
22+
- name: IMAGE
23+
description: The URI of the image to push, including registry host
24+
- name: DIRECTORY
25+
description: The subdirectory of the workspace/repo
26+
default: "."
27+
- name: HANDLER
28+
default: "function.handler"
29+
resources:
30+
- name: sources
31+
targetPath: /workspace
32+
type: git
3133
steps:
3234
- name: dockerfile
33-
image: gcr.io/kaniko-project/executor@sha256:30ba460a034a8051b3222a32e20cb6049741e58384e3adf8c8987c004e2f2ab9
35+
image: gcr.io/kaniko-project/executor:debug-v0.8.0
3436
command:
3537
- /busybox/sh
3638
args:
3739
- -c
3840
- |
39-
cd /workspace/${DIRECTORY}
41+
cd /workspace/workspace
4042
cat <<EOF > Dockerfile
4143
FROM gcr.io/triggermesh/knative-lambda-node10
42-
ENV _HANDLER "${HANDLER}"
44+
ENV _HANDLER "${inputs.params.HANDLER}"
4345
4446
COPY . .
4547
RUN npm install
4648
ENTRYPOINT ["/opt/aws-custom-runtime"]
4749
EOF
4850
- name: export
49-
image: gcr.io/kaniko-project/executor@sha256:30ba460a034a8051b3222a32e20cb6049741e58384e3adf8c8987c004e2f2ab9
51+
image: gcr.io/kaniko-project/executor:debug-v0.8.0
5052
args:
51-
- --context=/workspace/${DIRECTORY}
52-
- --dockerfile=/workspace/${DIRECTORY}/Dockerfile
53-
- --destination=${IMAGE}:${TAG}
53+
- --context=/workspace/workspace
54+
- --dockerfile=Dockerfile
55+
- --destination=${inputs.params.IMAGE}
5456
# Workaround not to use default config which requires gcloud credentials
5557
# to pull base image from public gcr registry
5658
# https://groups.google.com/d/msg/kaniko-users/r5yoP_Ejm_c/ExoEXksDBAAJ

node-4.x/buildtemplate.yaml renamed to node-4.x/runtime.yaml

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018 TriggerMesh, Inc
1+
# Copyright 2019 TriggerMesh, Inc
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,45 +12,47 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
apiVersion: build.knative.dev/v1alpha1
16-
kind: BuildTemplate
15+
apiVersion: tekton.dev/v1alpha1
16+
kind: Task
1717
metadata:
1818
name: knative-node4-runtime
1919
spec:
20-
parameters:
21-
- name: IMAGE
22-
description: The URI of the image to push, including registry host
23-
- name: TAG
24-
description: Tag of the image being pushed
25-
default: latest
26-
- name: DIRECTORY
27-
description: The subdirectory of the workspace/repo
28-
default: ""
29-
- name: HANDLER
30-
default: "function.handler"
20+
inputs:
21+
params:
22+
- name: IMAGE
23+
description: The URI of the image to push, including registry host
24+
- name: DIRECTORY
25+
description: The subdirectory of the workspace/repo
26+
default: "."
27+
- name: HANDLER
28+
default: "function.handler"
29+
resources:
30+
- name: sources
31+
targetPath: /workspace
32+
type: git
3133
steps:
3234
- name: dockerfile
33-
image: gcr.io/kaniko-project/executor@sha256:30ba460a034a8051b3222a32e20cb6049741e58384e3adf8c8987c004e2f2ab9
35+
image: gcr.io/kaniko-project/executor:debug-v0.8.0
3436
command:
3537
- /busybox/sh
3638
args:
3739
- -c
3840
- |
39-
cd /workspace/${DIRECTORY}
41+
cd /workspace/workspace
4042
cat <<EOF > Dockerfile
4143
FROM gcr.io/triggermesh/knative-lambda-node4
42-
ENV _HANDLER "${HANDLER}"
44+
ENV _HANDLER "${inputs.params.HANDLER}"
4345
4446
COPY . .
4547
RUN npm install
4648
ENTRYPOINT ["/opt/aws-custom-runtime"]
4749
EOF
4850
- name: export
49-
image: gcr.io/kaniko-project/executor@sha256:30ba460a034a8051b3222a32e20cb6049741e58384e3adf8c8987c004e2f2ab9
51+
image: gcr.io/kaniko-project/executor:debug-v0.8.0
5052
args:
51-
- --context=/workspace/${DIRECTORY}
52-
- --dockerfile=/workspace/${DIRECTORY}/Dockerfile
53-
- --destination=${IMAGE}:${TAG}
53+
- --dockerfile=Dockerfile
54+
- --context=/workspace/workspace
55+
- --destination=${inputs.params.IMAGE}
5456
# Workaround not to use default config which requires gcloud credentials
5557
# to pull base image from public gcr registry
5658
# https://groups.google.com/d/msg/kaniko-users/r5yoP_Ejm_c/ExoEXksDBAAJ

0 commit comments

Comments
 (0)