This demonstration describes how to produce a new Source to Image (S2I) runtime image to deploy web application running on liberty on OpenShift.
- Overview
- Bill of Materials
- Setup Instructions
- Build and Deployment
- Considerations on HTTP session failover
- Cleaning up
OpenShift provides several out of the box Source to Image builder images. To support deployments in Liberty, a new s2i builder image will be created to support a simplified deployment to OpenShift. Once the new image is produced, an example application will be deployed.
It makes use of the following technologies:
This demo should be run on an installation of OpenShift Enterprise V3.7
- Example JEE Application - Public repository for a simple JEE hello world app.
The openshift-applier will create the following OpenShift objects:
- A project named
liberty-demo
- Five ImageStreams named
websphere-liberty
,s2i-liberty
,hello-world-artifacts
,eap70-openshift
andhello-world
(see .openshift/templates/build.yml) - Three BuildConfigs named
websphere-liberty
,hello-world-artifacts
andhello-world
(see .openshift/templates/build.yml) - A DeploymentConfig named
hello-world
(see .openshift/templates/deployment.ym) - A Service named
hello-world
(see .openshift/templates/deployment.ym) - A Route named
hello-world
(see .openshift/templates/deployment.ym)
NOTE: This requires permission to create new projects and that the
liberty-demo
project doesn't already exist
There is no specific requirements necessary for this demonstration. The presenter should have an OpenShift Enterprise 3.7 environment available with access to the public Internet and the OpenShift Command Line Tools installed on their machine.
The following prerequisites must be met prior to beginning to build and deploy Liberty
- OpenShift Command Line Tool
- Openshift Applier to build and deploy artifacts and applications. As a result you'll need to have ansible installed The following steps are to be used to demonstrate two methods for producing the Source to Image builder image and deploying an application using the resulting image.
- Clone this repository:
git clone https://github.com/redhat-cop/containers-quickstarts
cd containers-quickstarts/build-s2i-liberty
- Run
ansible-galaxy install -r requirements.yml --roles-path=roles
- Login to OpenShift:
oc login -u <username> https://master.example.com:8443
- Run openshift-applier:
ansible-playbook -i .applier/hosts roles/openshift-applier/playbooks/openshift-cluster-seed.yml
Three new image builds will be kicked off automatically. They can be tracked by running oc logs -f bc/websphere-liberty
, oc logs -f bc/hello-world-artifacts
and oc logs -f bc/hello-world
respectively.
Last the deployment will kick of which can be tracked by running oc logs -f dc/hello-world
.
The application will be available at the context: hello-world-war-1.0.0
You can curl as follows:
curl -L http://$(oc get route hello-world --template '{{ .spec.host }}')/hello-world-war-1.0.0
You can set the following environment variable on containers running on images created with the Liberty s2i image:
Environment Variable | Default | Description |
---|---|---|
ENABLE_DEBUG | false | enable running the jvm in debug mode |
DEBUG_PORT | 7777 | port on which the jvm will listen for a debugger |
When liberty is deployed in a cloud environment, there are certain limitations that apply as explained in this document. With respect to the http session failover, two techniques generally apply:
- session replication: Liberty does not support session replication out-of-the-box. This feature can be implemented by integrating with eXtremeScale, as described in this article.
- session persistence: it is possible to persist the session using any database that support a JDBC connection. This article explains how to configure Liberty to do so.
oc delete project liberty-demo