Install Tasks

Tasks consist of a number of steps that are executed sequentially. Tasks are executed/run by creating TaskRuns.

A TaskRun will schedule a Pod. Each step is executed in a separate container within the same pod. They can also have inputs and outputs in order to interact with other tasks in the pipeline.

Here is an example of a Maven task for building a Maven-based Java application:

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: maven-build
spec:
  resources:
    inputs:
    - name: workspace-git
      targetPath: /
      type: git
  steps:
  - name: build
    image: maven:3.6.0-jdk-8-slim
    command:
    - /usr/bin/mvn
    args:
    - install

When a task starts running, it starts a pod and runs each step sequentially in a separate container on the same pod. Tasks can have one or multiple steps, and, since they run within the same pod, they have access to the same volumes in order to cache files, access configmaps, secrets, etc.

As mentioned previously, tasks can receive inputs (e.g. a git repository) and produce outputs (e.g. an image in a registry).

Note that only the requirement for a git repository is declared on the task and not a specific git repository to be used. That allows tasks to be reusable for multiple pipelines and purposes.

You can find more examples of reusable tasks in the Tekton Catalog and OpenShift Catalog repositories.

Install the apply-manifests and update-deployment tasks from the repository using oc or kubectl, which you will need for creating a pipeline in the next section:

oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/master/01_pipeline/01_apply_manifest_task.yaml
oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/master/01_pipeline/02_update_deployment_task.yaml

Alternatively, in the OpenShift Web Console, you can click on the + at the top right of the screen while you are in the pipelines-tutorial project and import the YAML files from apply-manifests and update-deployment

You can take a look at the tasks you created using the Tekton CLI:

tkn task ls

NAME                AGE
apply-manifests     10 seconds ago
update-deployment   4 seconds ago

We will be using buildah clusterTasks, which gets installed along with Operator. Operator installs few ClusterTask which you can see.

tkn clustertasks ls

NAME                       DESCRIPTION   AGE
buildah                                  1 day ago
buildah-v0-11-3                          1 day ago
jib-maven                                1 day ago
kn                                       1 day ago
maven                                    1 day ago
openshift-client                         1 day ago
openshift-client-v0-11-3                 1 day ago
s2i                                      1 day ago
s2i-dotnet-3                             1 day ago
s2i-dotnet-3-v0-11-3                     1 day ago
s2i-go                                   1 day ago
s2i-go-v0-11-3                           1 day ago
s2i-java-11                              1 day ago
s2i-java-11-v0-11-3                      1 day ago
s2i-java-8                               1 day ago
s2i-java-8-v0-11-3                       1 day ago
s2i-nodejs                               1 day ago
s2i-nodejs-v0-11-3                       1 day ago
s2i-perl                                 1 day ago
s2i-perl-v0-11-3                         1 day ago
s2i-php                                  1 day ago
s2i-php-v0-11-3                          1 day ago
s2i-python-3                             1 day ago
s2i-python-3-v0-11-3                     1 day ago
s2i-ruby                                 1 day ago
s2i-ruby-v0-11-3                         1 day ago
s2i-v0-11-3                              1 day ago
tkn                                      1 day ago

Last updated