Skip to main contentModernization   Playbook

Modernizing operations using traditional WAS

Deploy to OpenShift

This section covers how to deploy a containerized traditional WebSphere Application Server application to run on Red Hat OpenShift Container Platform using OpenShift Pipelines.

The diagram below shows the flow of the pipeline which starts when the developer checks their code in to Git and ends with the application being deployed in a build namespace. The diagram below shows the following flow:

  • 1) A developer commits code to the application repository

  • 2) A webhook starts a tekton pipeline running in the build project

  • 3) A tekton task clones the application source code (4) from the application repository, uses Maven to compile and test the application before using buildah to create a image which is pushed to the image registry (5)

  • 6) A tekton task deploys the application to the local namespace using the image from the image registry (7)

    Pipeline

Deploy the Application

The following steps will deploy the modernized Customer Order Services application in a Traditional WAS container to a Red Hat OpenShift cluster.

Prerequisites

You will need the following:

Getting the project repository

You can clone the repository from its main GitHub repository page and checkout the appropriate branch for this version of the application.

git clone https://github.com/ibm-cloud-architecture/appmod-twas-tekton.git
cd appmod-twas-tekton

Create application database infrastructure

As said in the prerequisites section above, the Customer Order Services application uses uses DB2 as its database. Follow these steps to create the appropriate database, tables and data the application needs to:

  • Copy the createOrderDB.sql and initialDataSet.sql files you can find in the Common directory of this repository over to the db2 host machine (or git clone the repository) in order to execute them later.

  • ssh into the db2 host

  • Change to the db2 instance user: `su {database_instance_name}“

  • Start db2: db2start

  • Create the ORDERDB database: db2 create database ORDERDB

  • Connect to the ORDERDB database: db2 connect to ORDERDB

  • Execute the createOrderDB.sql script you copied over in step 1 in order to create the appropriate tables, relationships, primary keys, etc: db2 -tf createOrderDB.sql

  • Execute the initialDataSet.sql script you copied over in step 1 to populate the ORDERDB database with the needed initial data set: db2 -tf initialDataSet.sql

If you want to re-run the scripts, please make sure you drop the databases and create them again.

Create the build project

Create the project that will be used for the Tekton pipeline and the initial deployment of the application.

Issue the command shown below to create the project:

oc new-project cos-twas-tekton

Import the Tekton resources

Import the Tekton Tasks, Pipeline and PipelineResources in to the project using the commands shown below:

cd tekton/tekton-only
oc apply -f gse-apply-manifests-pvc-task.yaml
oc apply -f gse-buildah-pvc-task.yaml
oc apply -f gse-build-deploy-pvc-pipeline.yaml
oc apply -f gse-build-pipeline-resources.yaml

Run the pipeline

The recommended way to trigger the pipeline would be via a webhook (link) but for simplicity the command line can be used. Issue the command below to trigger the pipeline:

tkn pipeline start gse-build-deploy-pvc-pipeline -n cos-twas-tekton

When prompted, accept the default git-source value as shown below:

Pipeline

When prompted, accept the default docker-image value as shown below:

Pipeline1

View the pipeline logs

  • In the OpenShift Container Platform UI, change to the Developer view, select the cos-twas-tekton project and then select Pipelines. Click on the Last Run

    Pipeline
  • Select Logs

    Pipeline Logs
  • The pipeline will execute and the logs will be displayed

    Pipeline Logs
  • Once both the gse-build and gse-apply-manifests steps are complete, the pipeline is finished.

Validate the application

Now that the pipeline is complete, validate the Customer Order Services application is deployed and running in cos-twas-tekton project

  • In the OpenShift Console, navigate to Topology view and click on the cos-twas Deployment to view deployment details, including Pods Services and Routes

Topology

Deployment

  • From this view you can also view the route for the application. Note that the URL is < application_name >-< project_name >.< ocp cluster url >. In this case the project name is cos-liberty-tekton

    Route
  • Add /CustomerOrderServicesWeb to the end of the URL in the browser to access the application

    Dev Running
  • Log in to the application with username: rbarcia and password: bl0wfish

Review and Next Steps

In this section you configured a CI/CD pipeline for the CustomerOrderServices application that builds a single immutable image for the latest version of the application and then deploys it to a dev environment.