OpenShift and Tekton featured image

I recently heard about Tekton as an alternative for Jenkins on Red Hat OpenShift. What got my attention was that Tekton uses Operators as building blocks, and Operators are something I am also interested in. I don't want to get ahead of myself, though; so we'll start with installing Tekton on Red Hat OpenShift. Installing on Kubernetes is also possible, but for now the focus is on OpenShift.

To install Tekton, you need to be cluster-admin on a Red Hat OpenShift cluster. The reason for that is that the Controller must run with anyuid. Just have an OpenShift or Minishift cluster at your fingertips on which you can be cluster-admin.

We are going to use a dedicated project to install the Tekton Operators in:

oc new-project tekton-pipelines --display-name='Tekton Pipelines'
oc adm policy add-scc-to-user anyuid -z tekton-pipelines-controller
oc apply --filename

This creates two deployments in the tekton-pipelines project, named tekton-pipelines-controller and tekton-pipelines-webhook. It is fast to start up, but to see if the pods are running, use the following oc command and wait for the 'Running' status:

oc get pods --namespace tekton-pipelines --watch

Use CTRL + C to exit watch mode.

Now that Tekton is running, we need to define a Task with steps saying what to do. We also need a TaskRun definition saying which Task to run. We need two yaml files for that. How the files are named does not really matter, but I am using the convention to end them with -task.yaml and -task-run.yaml.

A Task definition file named echo-hello-world-task.yaml:

kind: Task
  name: echo-hello-world-task
    - name: echo
      image: ubuntu
        - echo
        - "hello world"

And a TaskRun definition file named echo-hello-world-task-run.yaml:

kind: TaskRun
  name: echo-hello-world-task-run
    name: echo-hello-world-task

We will apply the two files with the following commands:

oc apply -f echo-hello-world-task.yaml
oc apply -f echo-hello-world-task-run.yaml

As soon as both files are applied they will get directly executed. To follow the output of the TaskRun, use the command:

oc get taskruns/echo-hello-world-task-run -o yaml

Look through the output and search for:

    - lastTransitionTime: 2019-07-08T18:48:15Z
      status: "True"
      type: Succeeded

If it looks almost the same as above, you have executed the first part of what will become a complete Tekton pipeline.

Last updated: September 10, 2020