Skip to main contentCloud Native Reference Implementation

Deploy Storefront Microservices onto Openshift 4.6 using Cloudnative toolkit

Introduction

Today you will be learning how to deploy all storefront microservices on Openshift using Cloudnative toolkit with the help of Tekton.

Storefront Architecture

Table of Contents

Pre-requisites

Set Up Databases for Storefront

This section will demonstrate how to deploy all the databases that are required by the storefront application. This will show you how to deploy MySQL, Elasticsearch, CouchDB, and MariaDB databases.

Clone the repo

git clone https://github.com/ibm-garage-ref-storefront/storefront-databases.git
cd storefront-databases
chmod +x ./setup_databases.sh

Run the below command to deploy the databases on the openshift cluster where storefront-dev is the project name.

oc login --token={your-api-token} --server={your-servername}
./setup_databases.sh sf-quarkus-dev

The output should be something similar to what is shown below.

$ ./setup_databases.sh sf-quarkus-dev
NAMESPACE not set. Using parameter "sf-quarkus-dev"
=========================================================================
Set namespace
error: A project named "sf-quarkus-dev" does not exist on "https://c100-e.jp-tok.containers.cloud.ibm.com:30791".
Your projects are:
* calico-system
* default
* ibm-cert-store

Now access your new project

oc project sf-quarkus-dev

You should get an output similar to what is shown below

> oc project sf-quarkus-dev
Already on project "sf-quarkus-dev" on server "https://c100-e.jp-tok.containers.cloud.ibm.com:30791".

Upon completing this section you can see above all of your databases have been deployed onto your openshift cluster. To check the status, run the below command.

> oc get pods
NAME READY STATUS RESTARTS AGE
customer-couchdb-couchdb-0 2/2 Running 0 3m28s
customer-create-user-ktzzn 0/1 Completed 0 2m36s
elasticsearch-85b87b5fbd-6l4pk 1/1 Running 0 3m28s
inventory-mysql-57887c6745-p7cpk 1/1 Running 0 3m27s
inventory-populate-mysql-mwqqf 0/1 Completed 0 2m37s
orders-mariadb-0 1/1 Running 0 3m28s

Create an organization on Github

When you create a new organization from scratch, it doesn’t have any repositories associated with it.

Github has information on how to create an organization. View the link below for the steps:

Clone the storefront-repo-automator to run the script

You can manually create a new repo and added it onto your Github organization or you can use the script that we provided for you. Clone the repository storefront-repo-automator as shown below:

Once you have cloned the repository, make sure you run the following command:

git clone https://github.com/ibm-garage-ref-storefront/storefront-repo-automator
cd storefront-repo-automator
export org={your-github-org-you-created}
./run.sh

After running the storefront-repo-automator, you should be able to see the storefront repositories as shown below.

Storefront

Deploy Microservices to Openshift using toolkit

Today you will learning how to deploy all microservices to Openshift using Tekton. To achieve this, you must run the following steps:

  • Login into the cluster using oc login.

  • Sync the project to get all the necessary configurations.

oc sync sf-quarkus-dev

Inventory Microservice

  • Clone the inventory-ms-quarkus repo.
git clone https://github.com/ibm-garage-ref-storefront/inventory-ms-quarkus.git
cd inventory-ms-quarkus
  • To trigger the pipeline, run the below command.
oc pipeline --tekton
  • Enter git credentials.

  • Use down/up arrow and select ibm-java-maven.

  • Hit Enter to enable image scanning.

  • Open the url to see the pipeline running in the OpenShift Console.

  • Verify that Pipeline Run completed successfully.

  • Grab the route.

oc get route inventory-ms-quarkus --template='{{.spec.host}}'

You will see something like below.

$ oc get route inventory-ms-quarkus --template='{{.spec.host}}'
inventory-ms-quarkus-sf-quarkus-openshift.storefront-cn-6ccd7f378ae819553d37d5f2ee142bd6-0000.che01.containers.appdomain.cloud
  • Now access the endpoint using https://<route_url>/micro/inventory.

Catalog Microservice

  • Clone the catalog-ms-quarkus repo.
git clone https://github.com/ibm-garage-ref-storefront/catalog-ms-quarkus.git
cd catalog-ms-quarkus
  • To trigger the pipeline, run the below command.
oc pipeline --tekton
  • Enter git credentials.

  • Use down/up arrow and select ibm-java-maven.

  • Hit Enter to enable image scanning.

  • Open the url to see the pipeline running in the OpenShift Console.

  • Verify that Pipeline Run completed successfully.

  • Grab the route.

oc get route catalog-ms-quarkus --template='{{.spec.host}}'

You will see something like below.

$oc get route catalog-ms-quarkus --template='{{.spec.host}}'
catalog-ms-quarkus-sf-quarkus-dev.mq-devops-6ccd7f378ae819553d37d5f2ee142bd6-0000.par01.containers.appdomain.cloud
  • Now access the endpoint using https://<route_url>/micro/items.

Set Up Keycloak operator

Follow the instructions here to install keycloak operator.

To set up storefront specific settings follow the instructions here.

Orders Microservice

  • Clone the orders-ms-quarkus repo.
git clone https://github.com/ibm-garage-ref-storefront/orders-ms-quarkus.git
cd orders-ms-quarkus

Note: Before triggering this pipeline, make sure you set up ibm-java-env secret with necessary info like KEYCLOAK_CLIENT_ID and KEYCLOAK_CLIENT_SECRET.

  • To trigger the pipeline, run the below command.
oc pipeline --tekton
  • Enter git credentials.

  • Use down/up arrow and select ibm-java-maven.

  • Hit Enter to enable image scanning.

  • Open the url to see the pipeline running in the OpenShift Console.

  • Verify that Pipeline Run completed successfully.

  • Grab the route.

oc get route orders-ms-quarkus --template='{{.spec.host}}'

You will see something like below.

$ oc get route orders-ms-quarkus --template='{{.spec.host}}'
orders-ms-quarkus-sf-quarkus-dev.mq-devops-6ccd7f378ae819553d37d5f2ee142bd6-0000.par01.containers.appdomain.cloud
  • Now access the endpoint using https://<route_url>/micro/items.

Customer Microservice

  • Clone the customer-ms-quarkus repo.
git clone https://github.com/ibm-garage-ref-storefront/customer-ms-quarkus.git
cd customer-ms-quarkus

Note: Before triggering this pipeline, make sure you set up ibm-java-env secret with necessary info like KEYCLOAK_CLIENT_ID and KEYCLOAK_CLIENT_SECRET.

  • To trigger the pipeline, run the below command.
oc pipeline --tekton
  • Enter git credentials.

  • Use down/up arrow and select ibm-java-maven.

  • Hit Enter to enable image scanning.

  • Open the url to see the pipeline running in the OpenShift Console.

  • Verify that Pipeline Run completed successfully.

  • Grab the route.

oc get route customer-ms-quarkus --template='{{.spec.host}}'

You will see something like below.

$ oc get route customer-ms-quarkus --template='{{.spec.host}}'
customer-ms-quarkus-sf-quarkus-dev.mq-devops-6ccd7f378ae819553d37d5f2ee142bd6-0000.par01.containers.appdomain.cloud
  • Now access the endpoint using https://<route_url>/micro/items.

Storefront UI

  • Clone the storefront-ui repo.
git clone https://github.com/ibm-garage-ref-storefront/storefront-ui.git
cd storefront-ui
git checkout hp-quarkus-version

Note: Before triggering this pipeline, make sure you set up ibm-java-env secret with necessary info like KEYCLOAK_CLIENT_ID and KEYCLOAK_CLIENT_SECRET.

  • To trigger the pipeline, run the below command.
oc pipeline --tekton
  • Enter git credentials.

  • Use down/up arrow and select ibm-nodejs.

  • Hit Enter to enable image scanning.

  • Open the url to see the pipeline running in the OpenShift Console.

  • Verify that Pipeline Run completed successfully.

  • Grab the route.

oc get route storefront-ui --template='{{.spec.host}}'

You will see something like below.

$ oc get route storefront-ui --template='{{.spec.host}}'
storefront-ui-sf-quarkus-dev.mq-devops-6ccd7f378ae819553d37d5f2ee142bd6-0000.par01.containers.appdomain.cloud
  • Now access the endpoint using https://<route_url>/micro/items.
Storefront
  • Once deployed successfully, you will be able to see the list of pipelines in the openshift web console as follows.
Storefront pipelines