This article is the final entry in a 5 part series. The series consists of:

Introduction

OpenShift Pipelines is a Continuous Integration / Continuous Delivery (CI/CD) solution based on the open source Tekton project. The previous articles in the series showed how to use Tekton to:

  • use the OpenShift source 2 image to build an application,
  • create and store a runtime image,
  • Create an overall orchestration process of Tekton pipelines to bring together the tasks explained so far in the series into a single seamless process that executes all required steps.

In this article the use of the source code and pipeline assets will be explained in detail such that the reader can create the process for themselves. Hopefully it can act as a template for a more creative build / test / deploy process to be created for your requirements.

The steps outlined in this article will do the following:

  1. Build an application from source code using Maven and the OpenShift Source to Image process
  2. Create a runtime container image
  3. Push the image to the Quay image repository
  4. Deploy the image into a project on OpenShift (after first clearing out the old version)

Access to the source content

All assets required to create your own instance of the resources described in this article can be found in the GitHub repository here. In an attempt to save space and make the article more readable only the important aspects of Tekton resources are included within the text. Readers who want to see the context of a section of YAML should clone or download the Git repository and refer to the full version of the appropriate file.

Using the example build process

If you want to experiment with the build process described in this article then you can easily do so. The prerequisite is that you have an OpenShift cluster with the OpenShift Pipelines operator installed.

Access to the source code and pipeline configuration

Although you will have a copy of the source code for the application and the yaml for the build process locally, remember that when the build runs it will clone the repository again and will use that code for the application build. The source code that you clone here is irrelevant, but it helps to keep together the source code and pipeline assets. Follow the steps below to create the content in your cluster:

  1. Clone or fork the Git repository and cd to the root of your local copy
    1. git clone https://github.com/marrober/pipelineBuildExample.git
    2. cd pipelineBuildExample

Create the OpenShift project and assets

  1. Create an OpenShift project
    1. If you want to change the project name feel free to change the references to the namespace in the yaml files.
    2. oc new-project liberty-rest
  2. Create the resources by executing the command :
    1. oc project liberty-rest
    2. cd build
    3. ./create-tasks.sh

Create a quay.io authentication secret

Generate and store in OpenShift the quay.io authentication secret with the following steps..

  1. Create an account on quay.io if you do not already have one.
  2. Login to quay.io in the web user interface and click on the username in the top right corner.
  3. Select account settings.
  4. Click the blue hyperlink ‘Generate Encrypted Password’.
  5. Re-enter your password when prompted.
  6. Select the second option in the pop up window for ‘Kubernetes secret’ .
  7. Download the file.
  8. Create a repository in the quay.io account to match the OpenShift project name. In this example the project name is ‘liberty-rest’
  9. Edit the secret file to change the name of the secret to be : quay-auth-secret.
  10. Create the secret using the command:
    1. oc create -f <filename>

Update parameters in the pipeline run

Update the pipeline run to match the quay.io account that you created.

Modify the file build/pipelineRun/pipelineRun.yaml to ensure the account name matches the quay.io account.

   - name: quay-io-account
    value: "xxxxxxxxxxxxx"

Test the pipeline

Execute the pipeline process using the command:

oc create -f pipelineRun/pipelineRun.yaml

Watch the build progress in the OpenShift web user interface under the pipelines section of the developer perspective, as shown in figure 1.

Figure 1 - Pipeline view in OpenShift web user interface

Click on the name of the pipeline to see the tasks within the pipeline shown as a flow diagram and then click on the Pipeline Runs tab to see the status of completed or running pipeline runs as shown in figure 2.

Figure 2 - Pipeline runs with one in progress

Select the name link for the running pipeline to see details of how far it has progressed as shown in figure 3.

Figure 3 - details of running pipeline

Each task on the running pipeline can be clicked to see the details of the steps within it.

Test the application

When the pipeline process has completed, perform the following steps to test the application. Use the curl command below to send a rest call to the application.

curl $(oc get route liberty-rest-route -o \

jsonpath='{"http://"}{.spec.host}')/System/propertiesJavaHome

The response should be similar to :

Java Home ~~~~~> /opt/java/openjdk/jre

Summary

This article showed how to use the example assets to create a pipeline execution process.

What’s next

Watch this space. More articles are planned covering the use of Tekton triggers to automate the pipeline execution based on actions taking place in GitHub.