Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions task/bentoml/0.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM ubuntu:19.10

ENV PATH /usr/bin:$PATH

RUN apt-get update
RUN apt-get update && apt-get install --no-install-recommends --yes python3 python3-pip python3-dev python-dev gcc g++ build-essential

RUN pip3 install numpy Cython setuptools

RUN pip3 --no-cache-dir install bentoml
29 changes: 29 additions & 0 deletions task/bentoml/0.2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# BentoML

This task allows operations on [BentoML](https://github.com/bentoml/BentoML) services.

## Why BentoML Task?

BentoML now supports the ability to retrieve artifact bundles via its cli. This will allow for in integration with CI, so models can be safely packaged into containers and deployed without any manual effort. The build context is auto-generated by BentoML and can be easily connected to CI/CD pipelines. This task offers a new pattern for data scientists.

## Parameters

* **YATAISERVICE**: Optional address of YataiService to connect to for command.

_default_: ""`

* **ARGS**: The arguments to pass to `bentoml` CLI. This parameter is required to run this task.

### Examples

Run `bentoml --help` for BentoML usage. Using the [Tekton CLI](https://github.com/tektoncd/cli/blob/main/docs/cmd/tkn_task_start.md) (`tkn`):

Use bentoml to retrieve a full ML build environment in the cwd:

```shell
tkn task start bentoml -p ARGS="retrieve ServiceName:20200616152703_9E2AD7","YATAISERVICE=10.10.10.1:50051 --target_dir=/workspace/storage"
```

## Platforms

The Task can be run on `linux/amd64` platform.
42 changes: 42 additions & 0 deletions task/bentoml/0.2/bentoml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: bentoml
labels:
app.kubernetes.io/version: "0.2"
annotations:
tekton.dev/categories: Automation, Integration & Delivery
tekton.dev/pipelines.minVersion: "0.50.0"
tekton.dev/tags: cli
tekton.dev/platforms: "linux/amd64"
spec:
description: >-
This task allows operations on BentoML services

BentoML now supports the ability to retrieve artifact bundles via its
cli. This will allow for in integration with CI, so models can be safely
packaged into containers and deployed without any manual effort. The
build context is auto-generated by BentoML and can be easily connected to
CI/CD pipelines. This task offers a new pattern for data scientists.

params:
- name: ARGS
type: array
description: BentoML CLI arguments to run
- name: YATAISERVICE
type: string
description: BentoML CLI arguments to run
default: ""
steps:
- name: bento
image: docker.io/iancoffey/bentoml-python3@sha256:ac99d45853efa4750bd4e5f6bc4ab9a7d7aedce57e7930bbb6ef643f9892915d #tag: latest
command: ["bentoml"]
args: ["$(inputs.params.ARGS)"]
env:
- name: "BENTOML__YATAI_SERVICE__URL"
value: "$(inputs.params.YATAISERVICE)"
workspaces:
- name: bentoml
description: The folder where bentoml will write state to
mountPath: /workspace/bentoml
14 changes: 14 additions & 0 deletions task/bentoml/0.2/tests/run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: tekton.dev/v1
kind: TaskRun
metadata:
name: bentoml-list-run
spec:
params:
- name: ARGS
value: ["list"]
taskRef:
name: bentoml
workspaces:
- name: bentoml
emptyDir: {}
128 changes: 128 additions & 0 deletions task/generate-build-id/0.2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# `buildid`

Given a base version, this task generates a unique build id by appending the base-version to the current timestamp.

## Install the Task

```
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/generate-build-id/0.2/generate-build-id.yaml
```

## Parameters

* **base-version**: The base version to use in the generated build id. _default_: `["1.0"]`

## Platforms

The Task can be run on `linux/amd64`, `linux/s390x`, `linux/arm64` and `linux/ppc64le` platforms.

## Platforms

The Task can be run on `linux/amd64` platform.

## Usage

### Include the task inside a taskrun
In this example, we will demonstrate how to use the task to generate the build id by including it in a taskrun definition called `taskrun.yaml`:

```
apiVersion: tekton.dev/v1
kind: TaskRun
metadata:
name: generate-build-id-run
spec:
params:
- name: base-version
value: "2.3.1"
taskRef:
name: generate-build-id
```

As can be seen from the example, the default `base-version` is being overridden by providing a new `base-version` value of `2.3.1` as input param to the task.

The taskrun definition is then applied by installing it in Kubernetes cluster as `kubectl apply -f taskrun.yaml`.
Logs from the executed task are then retrieved using `tkn taskrun logs generate-build-id-run`:

```
#\> tkn taskrun logs generate-build-id-run
[get-timestamp] Current Timestamp: 20200617-180133
[get-timestamp] 20200617-180133

[get-buildid] 2.3.1-20200617-180133

```

### Use the generated build id in another task in a pipeline definition
In this example, we will demonstrate how the generated build id can be used by another task by including them inside a pipeline definition.

In the following example two tasks are included in a pipeline definition called `pipeline.yaml`

```
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: pipeline-demo-generated-build-id
spec:
params:
- name: service-version
type: string
default: "3.1.1"
tasks:
- name: get-build-id
taskRef:
name: generate-build-id
params:
- name: base-version
value: $(params.service-version)
- name: build-api
taskRef:
name: build-service-api
params:
- name: build-id
value: "$(tasks.get-build-id.results.build-id)"
```
As can be seen from the example the first task generates the build id while the second task consumes the generated build id.
In the task to generate the build id, we override the default value of `base-version` using the value of the `service-version` pipeline parameter that has currently been set to a default value of 3.1.1.
In the task to build the service api, we then pass the generated build from the first task as its input param called `build-id`.
For the sake of completeness, here is what the task to build the service api (`build-service-api.yaml`) looks like:

```
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: build-service-api
spec:
params:
- name: build-id
description: ID of the current build
type: string
steps:
- name: display-buildid
image: bash:latest
script: |
#!/usr/bin/env bash
echo "Provided Build ID: $(inputs.params.build-id)"
```

As can be seen above, this task accepts a build id as its input and displays it in its one and only step.

The task to build the service api and pipeline are then installed using `kubectl apply -f build-service-api.yaml` and `kubectl apply -f pipeline.yaml`.
Once installed the pipeline is started using `tkn pipeline start pipeline-demo-generated-build-id`.
Logs from the executed pipeline demonstrate that the first task generated a build id while the second task consumed it:

```
#\> tkn pipeline start pipeline-demo-generated-build-id
? Value for param `service-version` of type `string`? (Default is `3.1.1`) 3.1.1
Pipelinerun started: pipeline-demo-generated-build-id-run-g7tgw

In order to track the pipelinerun progress run:
tkn pipelinerun logs pipeline-demo-generated-build-id-run-g7tgw -f -n default

#\> tkn pipelinerun logs pipeline-demo-generated-build-id-run-g7tgw
[get-build-id : get-timestamp] Current Timestamp: 20200617-181338
[get-build-id : get-timestamp] 20200617-181338

[get-build-id : get-buildid] 3.1.1-20200617-181338

[build-api : display-buildid] Provided Build ID: 3.1.1-20200617-181338
```
42 changes: 42 additions & 0 deletions task/generate-build-id/0.2/generate-build-id.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: generate-build-id
labels:
app.kubernetes.io/version: "0.2"
annotations:
tekton.dev/pipelines.minVersion: "0.50.0"
tekton.dev/categories: Build Tools
tekton.dev/tags: build-tool
tekton.dev/displayName: "buildid"
tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le,linux/arm64"
spec:
description: >-
Given a base version, this task generates a unique build id by appending
the base-version to the current timestamp.

params:
- name: base-version
description: Base product version
type: string
default: "1.0"
results:
- name: timestamp
description: Current timestamp
- name: build-id
description: ID of the current build
steps:
- name: get-timestamp
image: docker.io/library/bash:5.0.18@sha256:879f94a9da53dc064779e7a68339aecd60a9028ff884cacaa47ae752ca690404 #tag: 5.0.18
script: |
#!/usr/bin/env bash
ts=`date "+%Y%m%d-%H%M%S"`
echo "Current Timestamp: ${ts}"
echo ${ts} | tr -d "\n" | tee $(results.timestamp.path)
- name: get-buildid
image: docker.io/library/bash:5.0.18@sha256:879f94a9da53dc064779e7a68339aecd60a9028ff884cacaa47ae752ca690404 #tag: 5.0.18
script: |
#!/usr/bin/env bash
ts=`cat $(results.timestamp.path)`
buildId=$(inputs.params.base-version)-${ts}
echo ${buildId} | tr -d "\n" | tee $(results.build-id.path)
15 changes: 15 additions & 0 deletions task/generate-build-id/0.2/samples/build-service-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: build-service-api
spec:
params:
- name: build-id
description: ID of the current build
type: string
steps:
- name: display-buildid
image: bash:latest
script: |
#!/usr/bin/env bash
echo "Provided Build ID: $(inputs.params.build-id)"
22 changes: 22 additions & 0 deletions task/generate-build-id/0.2/samples/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: pipeline-demo-generated-build-id
spec:
params:
- name: service-version
type: string
default: "3.1.1"
tasks:
- name: get-build-id
taskRef:
name: generate-build-id
params:
- name: base-version
value: $(params.service-version)
- name: build-api
taskRef:
name: build-service-api
params:
- name: build-id
value: "$(tasks.get-build-id.results.build-id)"
10 changes: 10 additions & 0 deletions task/generate-build-id/0.2/samples/taskrun.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: tekton.dev/v1
kind: TaskRun
metadata:
name: generate-build-id-run
spec:
params:
- name: base-version
value: "2.3.1"
taskRef:
name: generate-build-id
10 changes: 10 additions & 0 deletions task/generate-build-id/0.2/tests/run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: tekton.dev/v1
kind: TaskRun
metadata:
name: generate-build-id-run
spec:
params:
- name: base-version
value: "1.0.0"
taskRef:
name: generate-build-id
Loading
Loading