IBM Z Day on Nov. 21: Discover the ideal environment for modern, mission-critical workloads. Learn more

Continuous delivery with Tekton Dashboards example

Example Health is a demo app we created to demonstrate application modernization. As often is the case in real life, it started out as two separate applications. When our business needs grew faster than we anticipated, we quickly needed to add analytic capabilities to our app.

In the vein of 12-factor application best practices, we split our workload into five microservices. This translates into the Example Health application consisting of five different images. Currently, we have all five of these services deployed into one Red Hat® OpenShift® on IBM Cloud™ cluster.

A recurring problem we had was that any time we had to deploy the application in a new cluster, the install took a long time. Thus, the impetus for this project — a Tekton Pipeline to deploy all of our clusters at once! Using Tekton reduced our deployment time from 45 minutes of clicking around and configuring down to 15 minutes and a few commands.

In this tutorial, I show you how to set up Tekton pipelines in your OpenShift cluster and then use it to speed up your deployment process.

Intro to our Example Health app

Here are the five images that make up our Example Health app:

Example Health application view

Images are instrumental in the deployment process of applications within OpenShift. This pipeline, in particular, uses several different deployment methods for the images in our OpenShift cluster:

  • The Patient UI service is constructed from Node.js code through OpenShift’s Source-to-Image functionality.
  • The Admin UI service is likewise PHP code built from source into an image.
  • The two analytics images are also built from Dockerfiles.
  • The JEE business logic image is deployed directly from Docker Hub.

Prerequisties

This tutorial assumes you have a Red Hat OpenShift on IBM Cloud cluster already provisioned.

If not, you can create one via the IBM Cloud web console or using the ibmcloud CLI. When using the latter, this tutorial may come in handy.

You will also need a few CLIs, including kubectl and oc. You can get them here

Steps

  1. Target your cluster
  2. Install Tekton, dashboard, and extensions
  3. Create service account
  4. Install Tasks
  5. Apply resources, Pipeline and run

1. Target your cluster

Log in to cloud.ibm.com and go to the overview page for your OpenShift cluster. Click on the OpenShift web console button in the upper right. Once on your web console, select the dropdown from the upper-right corner (the label contains your email address), and select Copy Login Command. Paste this command into your local console window.

It should resemble:

$ oc login https://c100-e.us-east.containers.cloud.ibm.com:XXXXX --token=XXXXXXXXXXXXXXXXXXXXXXXXXX

2. Install Tekton, dashboards, and extensions

The following commands will first install Tekton, then the Tekton Dashboard (a handy web interface), and finally some Tekton webhook extension into your OpenShift cluster.

$ kubectl apply --filename https://storage.googleapis.com/tekton-releases/previous/v0.5.2/release.yaml
$ kubectl apply --filename https://storage.googleapis.com/tekton-releases/dashboard/previous/v0.1.1/release.yaml
$ kubectl apply --filename https://github.com/tektoncd/dashboard/releases/tag/v0.1.1/webhooks-extension_release.yaml

Back in the web console, find your tekton-dashboard application and click on Add Route to obtain a URL with which to access your dashboard via a web browser.

3. Create a service account

To make sure the pipeline has the appropriate permissions to store images in the local OpenShift registry, you need to create a service account. Call it ‘pipeline’:

$ oc create serviceaccount pipeline
$ oc adm policy add-scc-to-user privileged -z pipeline
$ oc adm policy add-role-to-user edit -z pipeline

4. Install tasks

Tekton Pipelines generally are constructed of individual tasks. In this tutorial, we use a couple of tasks maintained by the both the Tekton and OpenShift communities:

  • openshift-client allows you to execute CLI commands against your OpenShift cluster.
  • s2i-node and s2i-php tasks build images via OpenShift’s source-to-image functionality.

To install these tasks use:

$ oc create -f https://raw.githubusercontent.com/tektoncd/catalog/master/openshift-client/openshift-client-task.yaml
$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-catalog/master/s2i-nodejs/s2i-nodejs-task.yaml
$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-catalog/master/s2i-php/s2i-php-7-task.yaml

5. Apply resources, Pipeline, and run

Now you just need to apply a couple of files to the cluster.

The first, ‘example-health-resources’ defines the location of the GitHub repositories and the names you will use for the images you create as they are stored in the registry. As you can probably guess, the example-health-pipeline files define all the steps of our pipeline: building, deploying, and exposing our images.

Note: While the Patient and Admin UI parts of the Example Health application work out-of-the-box, the Analytics section needs futher information to fully function. You need to edit example-health-pipeline.yaml and provide a Mapbox access token, the name of your cluster, and your hash (found in the URL of your dashboard) and Mongo datalake credentials. See the Analytics repo for more details. You also need to expose the ports in the analytics services to their routes once the cluster is set up.

$ git clone https://github.com/loafyloaf/example-health-pipeline.git
$ cd example-health-pipeline
$ kubectl apply -f example-health-resources.yaml
$ kubectl apply -f example-health-pipeline.yaml

You can then use the Tekton dashboard to run your pipeline by selecting the Example Health Pipeline from the list of pipelines and then clicking the Create Pipeline Run button in the upper-right corner.

Once created, you can follow along with the progress of your pipeline run. Success looks similar to:

success

Back in your web console, you can see the URLs for your applications listed in the overview:

routes

Summary

Using Tekton pipelines has saved us nearly 30 minutes when deploying our applications in a new cluster. Hopefully the steps here will show you how to set up Tekton Pipelines in your own Red Hat OpenShift environment.

Olaph Wagoner