Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s2i-liberty #4

Merged
merged 42 commits into from
Oct 14, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1d45bab
s2i-liberty initial commit
raffaelespazzoli Sep 27, 2016
3cef661
fixed repo
raffaelespazzoli Sep 27, 2016
04fa257
added readme
raffaelespazzoli Sep 28, 2016
dfc8d5a
deleted test directory
raffaelespazzoli Sep 28, 2016
ea42cbc
fixed missing bashang in run command
raffaelespazzoli Sep 28, 2016
97d40b5
Update readme.md
raffaelespazzoli Sep 30, 2016
12666fa
Update readme.md
raffaelespazzoli Sep 30, 2016
23bf58a
added two build approach
raffaelespazzoli Oct 6, 2016
6da266e
added ability to debug liberty
raffaelespazzoli Oct 6, 2016
923ac20
added echo statements to build
raffaelespazzoli Oct 6, 2016
5f74db7
debug port
raffaelespazzoli Oct 6, 2016
64325ec
a
raffaelespazzoli Oct 6, 2016
cb019e4
d
raffaelespazzoli Oct 6, 2016
e2bc269
d
raffaelespazzoli Oct 6, 2016
b073470
d
raffaelespazzoli Oct 6, 2016
c5e6088
jolokia
raffaelespazzoli Oct 7, 2016
17015a7
improved jolokia
raffaelespazzoli Oct 7, 2016
5811643
run debug
raffaelespazzoli Oct 7, 2016
1ea2747
debug run
raffaelespazzoli Oct 7, 2016
7970be5
run debug
raffaelespazzoli Oct 7, 2016
86ad4bf
debug run
raffaelespazzoli Oct 7, 2016
3060150
debug jolokia
raffaelespazzoli Oct 7, 2016
5deb6e3
jolokia debug
raffaelespazzoli Oct 7, 2016
fbf5906
jolokia debug
raffaelespazzoli Oct 7, 2016
2ae50b8
Merge branch 'master' of
raffaelespazzoli Oct 7, 2016
d5560c3
jolokia debug
raffaelespazzoli Oct 7, 2016
a416fb4
jolokia debug
raffaelespazzoli Oct 7, 2016
8d34e3f
jolokia debug
raffaelespazzoli Oct 7, 2016
24e192c
jolokia debug
raffaelespazzoli Oct 7, 2016
2ec145d
jolokia debug
raffaelespazzoli Oct 7, 2016
57f9d58
no jolokia
raffaelespazzoli Oct 8, 2016
13c05c5
improved cohexistance of chained builds and extended build
raffaelespazzoli Oct 8, 2016
e7500dd
debug
raffaelespazzoli Oct 8, 2016
fd7e11d
debug
raffaelespazzoli Oct 8, 2016
67a4a38
fixed readme
raffaelespazzoli Oct 8, 2016
a4cf45d
readme fixes
raffaelespazzoli Oct 8, 2016
ed21fdb
d
raffaelespazzoli Oct 8, 2016
7dacd1e
last fix
raffaelespazzoli Oct 8, 2016
2a0cb63
correction for allowing a random user in root group to run the image
raffaelespazzoli Oct 10, 2016
909ec16
added application verification
raffaelespazzoli Oct 11, 2016
e29a787
fixed the md
raffaelespazzoli Oct 11, 2016
11863f1
fix
raffaelespazzoli Oct 11, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
jolokia
  • Loading branch information
raffaelespazzoli committed Oct 7, 2016
commit c5e6088ddb80f54fa0de59d4e09dda0fa339592b
7 changes: 5 additions & 2 deletions s2i-liberty/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ LABEL io.openshift.s2i.scripts-url=image:///usr/local/s2i \

ENV STI_SCRIPTS_PATH="/usr/local/s2i" \
WORKDIR="/usr/local/workdir" \
WLP_DEBUG_ADDRESS="7777"
WLP_DEBUG_ADDRESS="7777" \
JOLOKIA_PORT="8778"

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
Expand All @@ -28,14 +29,16 @@ RUN useradd -u 1001 -r -g 0 -s /sbin/nologin \
mkdir -p $WORKDIR/artifacts && \
mkdir -p $WORKDIR/config && \
chown -R 1001:0 $WORKDIR && \
ln $STI_SCRIPTS_PATH/assemble-runtime $STI_SCRIPTS_PATH/assemble
ln $STI_SCRIPTS_PATH/assemble-runtime $STI_SCRIPTS_PATH/assemble &&\
wget -L -o $WORDIR/jolokia.jar http://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-jvm/1.3.5/jolokia-jvm-1.3.5-agent.jar

COPY ./placeholder.txt $WORKDIR/artifacts
COPY ./placeholder.txt $WORKDIR/config

WORKDIR $WORKDIR

EXPOSE $WLP_DEBUG_ADDRESS
EXPOSE $JOLOKIA_PORT

USER 1001

Expand Down
134 changes: 24 additions & 110 deletions s2i-liberty/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

erase binary build
add patch command
add jolokia

# Liberty Source to Image Builder Demo

This demonstration describes how to produce a new Source to Image (S2I) runtime image to deploy web application running on liberty on OpenShift.
Expand Down Expand Up @@ -52,8 +56,6 @@ None

* [Example JEE Application](https://github.com/efsavage/hello-world-war) - Public repository for a simple JEE hello world app.

## Two build approach

### Setup Instructions

There is no specific requirements necessary for this demonstration. The presenter should have an OpenShift Enterprise 3.3 environment available with access to the public Internet and the OpenShift Command Line Tools installed on their machine.
Expand All @@ -78,14 +80,14 @@ Create a new project called *liberty-demo*
oc new-project liberty-demo
```

## Two build approach

### Produce s2i Liberty Image

The Liberty runtime image can be created using the [Git](https://docs.openshift.com/enterprise/latest/dev_guide/builds.html#source-code) or [Binary](https://docs.openshift.com/enterprise/latest/dev_guide/builds.html#binary-source) build source

In this example we will use a pre-existing builder image that can build maven based apps: `registry.access.redhat.com/jboss-eap-7/eap70-openshift`

##### Git Source

The content used to produce the Liberty runtime image can originate from a Git repository. Execute the following command to start a new image build using the git source strategy.:

```
Expand All @@ -106,27 +108,6 @@ Let's break down the command in further detail

A new image called *s2i-liberty* was produced and can be used to build Liberty applications in the subsequent sections.

##### Binary Source

Instead of referencing a git repository, the content can be provided directly to the OpenShift build process using a binary source build.

The first step is to obtain the source code containing the builder. Once the code has been obtained, navigate to the folder containing the Play Framework *Dockerfile*, and execute the following command to start a new image build using the binary source strategy:

```
oc new-build websphere-liberty:webProfile7 --name=liberty-runtime-s2i --strategy=docker --from-dir=. --binary=true
```

Let's break down the command in further detail

* `oc new-build` - OpenShift command to create a new build
* `websphere-liberty:webProfile7` - The location of the base Docker image for which a new ImageStream will be created
* `--from-dir` - Location of source code that will be used as the source for the build process. The contents will be tar'ed up and uploaded to the builder image.
* `--name=s2i-liberty` - Name for the build and resulting image
* `--strategy=docker` - Name of the OpenShift source strategy that is used to produce the new image
* `--binary=true` - Specifies this build will be of a binary source type

A new image called *s2i-liberty* was produced and can be used to build Play Framework applications in the subsequent sections.

#### Create the first s2i build

The first s2i build will create the artifact. For this buld we will use the `jboss-eap-7/eap70-openshift` which is capable of building a maven project.
Expand All @@ -135,6 +116,11 @@ Run the following command:
```
oc new-build --docker-image=registry.access.redhat.com/jboss-eap-7/eap70-openshift --code=https://github.com/efsavage/hello-world-war --name=hello-world-artifacts
```
wait for the build to complete, type:
```
oc logs -f bc/hello-world-artifacts
```

#### Create the second s2i build

The second s2i build grabs the artifacts created by the first image and puts them in the expected locations in the Liberty image.
Expand All @@ -143,7 +129,10 @@ Run the following command:
```
oc new-build --image-stream=liberty-runtime-s2i --name=hello-world --source-image=hello-world-artifacts --source-image-path=/opt/eap/standalone/deployments/hello-world-war-1.0.0.war:artifacts
```

wait for the build to complete, type:
```
oc logs -f bc/hello-world
```

### Create a new Application

Expand All @@ -161,60 +150,18 @@ Let's break down the command in further detail
* `-i=hello-world` - Name of the ImageStream that contains the result of the build config that uses the extended s2i process
* `--name=hello-world` - Name to be applied to the newly created resources

The build that was triggered by the `new-app` command can be found by executing the following command:

```
oc get builds -l=app=hello-world
```

View the build logs by executing the following command:

```
oc logs builds/<build_name>
```

*Note: Replace `<build_name>` with the name of the build found in the previous command.*

Once the build completes, the application will be deployed.

## Extended build approach

### Setup Instructions

There is no specific requirements necessary for this demonstration. The presenter should have an OpenShift Enterprise 3.3 environment available with access to the public Internet and the OpenShift Command Line Tools installed on their machine.

### Presenter Notes

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.

#### Environment Setup

Using the OpenShift CLI, login to the OpenShift environment.


```
oc login <OpenShift_Master_API_Address>
```

Create a new project called *liberty-demo*


```
oc new-project liberty-demo
```

### Produce s2i Liberty Image

The Liberty runtime image can be created using the [Git](https://docs.openshift.com/enterprise/latest/dev_guide/builds.html#source-code) or [Binary](https://docs.openshift.com/enterprise/latest/dev_guide/builds.html#binary-source) build source

In this example we will use a pre-existing builder image that can build maven based apps: `registry.access.redhat.com/jboss-eap-7/eap70-openshift`

##### Git Source

The content used to produce the Liberty runtime image can originate from a Git repository. Execute the following command to start a new image build using the git source strategy.:

```
oc new-build websphere-liberty:webProfile7~https://github.com/raffaelespazzoli/containers-quickstarts --context-dir=s2i-liberty --name=liberty-runtime-s2i --strategy=docker
oc new-build websphere-liberty:webProfile7~https://github.com/redhat-cop/containers-quickstarts --context-dir=s2i-liberty --name=liberty-runtime-s2i --strategy=docker
```

Let's break down the command in further detail
Expand All @@ -229,39 +176,21 @@ Let's break down the command in further detail

*Note: If the repository was moved to a different location (such as a fork), be sure to reference to correct location.*

A new image called *s2i-liberty* was produced and can be used to build Liberty applications in the subsequent sections.

##### Binary Source
A new image called *liberty-runtime-s2i* was produced and can be used to build Liberty applications in the subsequent sections.

Instead of referencing a git repository, the content can be provided directly to the OpenShift build process using a binary source build.

The first step is to obtain the source code containing the builder. Once the code has been obtained, navigate to the folder containing the Play Framework *Dockerfile*, and execute the following command to start a new image build using the binary source strategy:

```
oc new-build websphere-liberty:webProfile7 --name=s2i-liberty --strategy=docker --from-dir=. --binary=true
```

Let's break down the command in further detail

* `oc new-build` - OpenShift command to create a new build
* `websphere-liberty:webProfile7` - The location of the base Docker image for which a new ImageStream will be created
* `--from-dir` - Location of source code that will be used as the source for the build process. The contents will be tar'ed up and uploaded to the builder image.
* `--name=s2i-liberty` - Name for the build and resulting image
* `--strategy=docker` - Name of the OpenShift source strategy that is used to produce the new image
* `--binary=true` - Specifies this build will be of a binary source type

A new image called *s2i-liberty* was produced and can be used to build Play Framework applications in the subsequent sections.

#### Create the first build config
#### Create the build config

In order to use the extended s2i process we need to configure the build config with some additional pieces of information. There does not appear to be a way to do this directly from the command line so we will use a two-phase approach.

First we will create a standard build config using the git source apporach explained above. Run the follwoing command:
```
oc new-build --docker-image=registry.access.redhat.com/jboss-eap-7/eap70-openshift --code=https://github.com/efsavage/hello-world-war --name=hello-world
```
Second modify the newly created build config to look as follows:
Second modify the newly created build config with the following patch command:
```
oc patch bc hello-world -p '
strategy:
type: Source
sourceStrategy:
from:
kind: ImageStreamTag
Expand All @@ -271,7 +200,8 @@ Second modify the newly created build config to look as follows:
name: 'liberty-runtime-s2i:latest'
runtimeArtifacts:
- sourcePath: /opt/eap/standalone/deployments/hello-world-war-1.0.0.war
destinationDir: artifacts
destinationDir: artifact
'
```
notice that the source strategy has two additional sections:
* `runtimeImage`: which defines the runtime image to be used during the build
Expand Down Expand Up @@ -301,22 +231,6 @@ Let's break down the command in further detail
* `-i=hello-world` - Name of the ImageStream that contains the result of the build config that uses the extended s2i process
* `--name=hello-world` - Name to be applied to the newly created resources

The build that was triggered by the `new-app` command can be found by executing the following command:

```
oc get builds -l=app=hello-world
```

View the build logs by executing the following command:

```
oc logs builds/<build_name>
```

*Note: Replace `<build_name>` with the name of the build found in the previous command.*

Once the build completes, the application will be deployed.

## Considerations on http session failover

When liberty is deployed in a cloud environment, there are certain limitations that apply as explained in this [document](http://www.ibm.com/support/knowledgecenter/en/SSD28V_8.5.5/com.ibm.websphere.wlp.core.doc/ae/cwlp_paas_restrict.html).
Expand Down
2 changes: 1 addition & 1 deletion s2i-liberty/s2i/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

#comment this line to disable debug
echo $'\n'JAVA_DEBUG="-Dwas.debug.mode=true -Dcom.ibm.websphere.ras.inject.at.transform=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${WLP_DEBUG_ADDRESS}"$'\n' >> /opt/ibm/wlp/usr/servers/defaultServer/server.env

echo "-javaagent:$WORKDIR/jolokia.jar=port=$JOLOKIA_PORT,protocol=https,caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt,clientPrincipal=cn=system:master-proxy,useSslClientAuthentication=true,extraClientCheck=true,host=0.0.0.0,discoveryEnabled=false"$'\n' >> /opt/ibm/wlp/usr/servers/defaultServer/server.env
/opt/ibm/wlp/bin/server run defaultServer