Giter VIP home page Giter VIP logo

app-modernization-openshift-templates-lab-iks's Introduction

IBM Client Developer Advocacy App Modernization Series

Lab - Migrating Legacy JEE apps to OpenShift on the IBM Cloud Kubernetes Service

Working with S2I and Templates

Overview

S2I in a tool deployed in OpenShift that provides a repeatable method to generate application images from source/binary code Templates provide a parameterized set of objects that can be processed by OpenShift. Templates provide a parameterized set of objects that can be processed by OpenShift.

In this lab you'll use these capabilities can be used to deploy a small legacy Java EE app to OpenShift on the IBM Cloud Kubernetes Service.

Step 1: Logon into the OpenShift Web Console and to the OpenShift CLI

1.1 Go to your IBM Cloud resource list https://cloud.ibm.com/resources

1.2 Click on your designated OpenShift cluster

Your designated cluster

1.3 Click on OpenShift web console

Web console

1.4 From the OpenShift web console click on your username in the upper right and select Copy Login Command

Copy Login Command

1.5 Paste the login command in a terminal window and run it (Note: leave the web console browser tab open as you'll need it later on in the lab)

Step 2: Clone the WebSphere Liberty S2I image source, create a Docker image, and push it to the OpenShift internal registry

2.1 Clone the the WebSphere Liberty S2I image source by issuing the following commands in the terminal window you just used to login via the CLI

git clone https://github.com/IBMAppModernization/s2i-liberty-javaee7.git
cd s2i-liberty-javaee7

2.2 Get the hostname of your OpenShift internal registry so you can push images to it

export INTERNAL_REG_HOST=`oc get route docker-registry --template='{{ .spec.host }}' -n default`

2.3 Create a new OpenShift project for this lab

oc new-project pbw-liberty-mariadb

2.4 Build the S2I Liberty image and tag it appropriately for the internal registry

docker build -t $INTERNAL_REG_HOST/`oc project -q`/s2i-liberty-javaee7:1.0 .

2.5 Login to the internal registry

docker login -u `oc whoami` -p `oc whoami -t` $INTERNAL_REG_HOST

2.6 Push the S2I Liberty image to the internal registry

 docker push $INTERNAL_REG_HOST/`oc project -q`/s2i-liberty-javaee7:1.0

Step 3: Install MariaDB from the OpenShift template catalog

3.1 In your Web console browser tab under My Projects click on View All

View All

3.2 Click on the pbw-liberty-mariadb project

3.3 Click on Browse Catalog

3.4 Select the Databases category, click MariaDB and then MariaDB (Ephemeral)

Create MariaDB

3.5 Click Next

3.6 Enter the following values for the fields indicated below (leave remaining values at their default values)

Field name Value
MariaDB Connection Username pbwadmin
MariaDB Connection Password l1bertyR0cks
MariaDB Database Name plantsdb

When you're done the dialog should look like the following:

DB values

3.7 Scroll down to the Labels section and change the app label value to pbw-liberty-mariadb

App label

3.8 Click Next

3.9 Under Create a binding for MariaDB (Ephemeral) select Create a secret in pbw-liberty-mariadb to be used later

3.10 Click Create and then click Continue to the project overview

Continue

3.11 Verify that the Pod for the MariaDB deployment eventually shows as running

Pod running

Step 4: Clone the Github repo that contains the code for the Plants by WebSphere app

4.1 Login in your Github account

4.2 In the search bar at the top left type in app-modernization-plants-by-websphere-jee6

Search results

4.3 Select the repository IBMAppModernization\app-modernization-plants-by-websphere-jee6 and then click on the Fork icon

4.4 Click the Clone or download button from your copy of the forked repo and copy the HTTPS URL to your clipboard

Clone URL

4.5 From your terminal go back to your home directory

cd ~

4.6 From the client terminal window clone the Git repo with the following commands appending the HTTPS URL from your clipboard

git clone [HTTPS URL for NEW REPO]
cd app-modernization-plants-by-websphere-jee6

Step 5: Install the Plants by WebSphere Liberty app using a template that utilizes S2I to build the app image

5.1 Add the Plants by WebSphere Liberty app template to your OpenShift cluster

oc create -f openshift/templates/pbw-liberty-template.yaml

5.2 In your Web console browser tab make sure you're in the pbw-liberty-mariadb project (top left) and click on Add to Project -> Browse Catalog (top right)

View All

5.3 Select the Other category and then click Plants by WebSphere on Liberty

5.4 Accept all the default values and click Create

5.5 Click Continue to the project overview

5.6 Wait until the Pod for the Plants by WebSphere app on Liberty shows as running and then click on the route to get to the app's endpoint

Launch app

Step 6: Test the Plants by WebSphere app

6.1 From the Plants by WebSphere app UI, click on the HELP link

Running app

6.2 Click on Reset database to populate the MariaDB database with data

6.3 Verify that browsing different sections of the online catalog shows product descriptions and images.

Online catalog

Summary

With even small simple apps requiring multiple OpenShift objects, templates greatly simplify the process of distributing OpenShift apps. S2I allows you to reuse the same builder image for apps on the same app server, avoiding the effort of having to create unique images for each app.

app-modernization-openshift-templates-lab-iks's People

Contributors

djccarew avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.