Example Health is a demo app the folks in my group created along with some other folks from the z/OS group. Initally, it was meant to demonstrate app moderization, but evolved over time to also include analytic capibilities. Currently, five different images constitute the Example Health app, and we have them all deployed into a single Red Hat OpenShift on IBM Cloud cluster, but anytime the app needs to be deployed in a new cluster the install can take a bit of time. Thus, the impitus for this project - a tekton pipeline to deploy them all! Using Tekton has reduced deployment time from 45 minutes of clicking around and configuring down to execution of a few commands and waiting for about 15 minutes.
This pipeline uses several methods for deploying images in OpenShift. The Patent UI image is constructed from node.js code via OpenShift's Source-to-image functionality; the Admin UI likewise from a php repository. The two analytics images are also build, but rather via Dockerfiles. The JEE business logic image is deployed directly from Docker Hub.
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
- Target your cluster
- Install Tekton
- Create service account
- Install Tasks
- Apply resources, pipeline and run
Login 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 into your local console window. It should resemble:
$ oc login https://c100-e.us-east.containers.cloud.ibm.com:XXXXX --token=XXXXXXXXXXXXXXXXXXXXXXXXXX
Back in your OpenShift web console, select Operators -> Operators Hub from the navigation menu on the left of your OpenShift web console and then search for the OpenShift Pipelines Operator.
Click on the tile and then the subsequent Install button.
Keep the default settings on the Create Operator Subscription page and click Subscribe.
To make sure the pipeline has the appropriate permissions to store images in the local OpenShift registry, we need to create a service account. We'll call it 'pipeline':
$ oc new-project example-health
$ oc create serviceaccount pipeline
$ oc adm policy add-scc-to-user privileged -z pipeline
$ oc adm policy add-role-to-user edit -z pipeline
Tekton Pipelines generally are constructed of individual tasks. We will be using 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, and the s2i-node
and s2i-php
tasks are responsible for building images via OpenShift's source-to-image functionality. To install:
$ oc create -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/openshift-client/0.1/openshift-client.yaml
$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-catalog/master/task/s2i-nodejs/0.1/s2i-nodejs.yaml
$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-catalog/master/task/s2i-php/0.1/s2i-php.yaml
Now we 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 we will use for the images we create as they are stored in the registry. As you can probably guess, the example-health-pipeline
file defines 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 health-pvc.yaml
$ kubectl apply -f example-health-resources.yaml
$ kubectl apply -f example-health-pipeline.yaml
You can then run your pipeline by executing the command:
$ kubectl apply -f health-pipeline-run.yaml
Once created, you can follow along with the progress of your pipeline run from the list of Pipelines --> Pipeline Runs in your cluster. Success looks similar to:
In your web console, navigate to Networking --> Routes to see the list of URLs for your applications:
Click on the URL listed for the patientui
to confirm installation:
This code pattern is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 and the Apache License, Version 2.