Lab - Building and Deploying a Fast-Moving Monolith

Return to Workshop

FAST-MOVING MONOLITH

FAST-MOVING MONOLITH ADVANTAGES

Step 1

First, deploy the coolstore monolith dev project (don’t forget to include -b app-partner when you run git clone - this is the branch in use for this lab!):

$ mkdir ~/coolstore
$ cd ~/coolstore
$ git clone -b app-partner https://github.com/epe105/monolith
$ cd monolith

Please update <USERNAME> below with your assigned username

$ oc new-project coolstore-<USERNAME>
$ oc process -f src/main/openshift/template.json | oc create -f -

Step 2

Notice there is no deployment yet as there is no build yet:

Step 3

Build the coolstore monolith (.war file) locally and deploy into the OpenShift via the binary build:

$ cd ~/coolstore/monolith
$ mvn clean package -Popenshift
$ oc start-build coolstore --from-file deployments/ROOT.war --follow

Step 4

In the web console, navigate to Builds → Images to see the new image created as a result of combining the monolith .war file with the JBoss EAP builder image

Step 5

Once the deployment is complete, navigate to the application by clicking on its route in the OpenShift web console Overview and exercise the app by adding/removing products to your shopping cart:

Step 6

Log into the database pod (with postgresql in the pod name) and inspect the values stored (you will need to copy/paste the password from the POSTGRESQL_PASSWORD environment variable when running the psql command):

Make note of POSTGRESQL_PASSWORD

$ oc env dc/coolstore-dev-postgresql --list       # copy value of POSTGRESQL_PASSWORD to clipboard

Make note of postgresql pod

$ oc get pods

oc rsh into postresql pod

$ oc rsh coolstore-dev-postgresql-1-3rfuw
sh-4.2$ psql -h $HOSTNAME -d $POSTGRESQL_DATABASE -U $POSTGRESQL_USER
Password for user userV31:XXXXXXXX
psql (9.5.4)
Type "help" for help.

monolith=> select * from INVENTORY;
monolith=> select * from PRODUCT_CATALOG;

Exit out of psql and then the postgresql pod

monolith=> \q
sh-4.2$ exit
exit

Step 7

Create the production deployment objects that will be used to promote builds from dev to prod using the supplied CI/CD pipeline:

$ oc process -f ~/coolstore/monolith/src/main/openshift/template-prod.json | oc create -f -

Step 8

Inspect the pipeline and observe the steps it executes during the pipeline run. Notice at the end of the script, the latest coolstore image is tagged with :prod, triggering a production deployment:

$ oc get bc/monolith-pipeline -o yaml
...
          openshiftTag(sourceStream: 'coolstore', sourceTag: 'latest', namespace: '', destinationStream: 'coolstore', destinationTag: 'prod', destinationNamespace: '')
...

Step 9

Wait for the jenkins service to be completely available, then execute the pipeline by navigating to Builds→ Pipelines and click on Start Pipeline next to the Monolith Pipeline:

Step 10

Return to the Overview page, wait for the deployment to complete, then click on the route for the coolstore-prod deployment to test the production app (identical to coolstore-dev).

Step 11

You should now have two identical copies of the app deployed, along with two databases:

Step 12

Scale down the coolstore-dev environment by clicking the down arrow next to the coolstore-dev and coolstore-dev-postgresql pods:

If your build pipeline fails to start, you can manually tag the images:

$ oc tag coolstore:latest coolstore:prod

Return to Workshop