First Fuse application on OpenShift V3.1

Since mid of December 2015, Red Hat has released the initial version of the Fuse Integration Services. These are various pre-build images which are aimed to make the implementation of Red Hat JBoss Fuse applications on OpenShift V3 as seamless as possible.

In this blog I will document the steps required to create a first application, using the Source-to-Image ( S2I ) builder images.

Step 1: create a git repository

The S2I builder will expect the sourcecode to be available via some git repository, so to start fresh, I created an empty on on github.com and cloned the empty repo to my local development environment

[psteiner@master ~]$ git clone https://github.com/PatrickSteiner/fuseOSE.git

Step 2: Create a new project in OpenShift

MacBook-Pro:Demos psteiner$ oc new-project xpaas
Now using project "xpaas" on server "https://master.example.com:8443".

Step 3: Import the required builder image into your project

If you, like I did, upgrade your Openshift environment from V3 to V3.1 then the builder images are not there yet. This requires us to manually create them. In the future, these will be part of the base installation procedure, so this step will become obsolete.

MacBook-Pro:Demos psteiner$ oc create  -f https://raw.githubusercontent.com/jboss-fuse/application-templates/master/fis-image-streams.json
imagestream "fis-java-openshift" created
imagestream "fis-karaf-openshift" created

Please also note, that I have created the builder images into my project/namespace. I could have also created them in any other project, like e.g. ‘openshift’.

Step 4: Create a new maven project

MacBook-Pro:Demos psteiner$ mvn archetype:generate -DarchetypeCatalog=https://repo.fusesource.com/nexus/content/groups/public/io/fabric8/archetypes/archetypes-catalog/2.2.0.redhat-079/archetypes-catalog-2.2.0.redhat-079-archetype-catalog.xml

removed lot’s of downloads …

[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:

removed lot’s of entries …

1: https://repo.fusesource.com/nexus/content/groups/public/io/fabric8/archetypes/archetypes-catalog/2.2.0.redhat-079/archetypes-catalog-2.2.0.redhat-079-archetype-catalog.xml -> io.fabric8.archetypes:karaf-camel-log-archetype (Creates a new Camel Log Example)
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 11

removed lot’s of downloads …

Define value for property 'groupId': : com.redhat.demo
Define value for property 'artifactId': : xpaas
Define value for property 'version': 1.0-SNAPSHOT: :
Define value for property 'package': com.redhat.demo: :
Confirm properties configuration:
groupId: com.redhat.demo
artifactId: xpaas
version: 1.0-SNAPSHOT
package: com.redhat.demo
 Y: : Y

removed a few entries …

INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.945 s
[INFO] Finished at: 2016-01-05T16:44:02+01:00
[INFO] Final Memory: 14M/204M
[INFO] ------------------------------------------------------------------------
MacBook-Pro:fuse_xpaas_demo psteiner$

We should now have a the created artifacts for the creation of the JBoss Fuse application on OpenShift.

MacBook-Pro:Demos psteiner$ ll fuse_xpaas_demo/
total 64
drwxr-xr-x 9 psteiner staff 306 Jan 5 16:52 .
drwxr-xr-x 10 psteiner staff 340 Jan 4 12:54 ..
drwxr-xr-x 13 psteiner staff 442 Jan 4 12:43 .git
-rw-r--r-- 1 psteiner staff 93 Jan 4 12:43 .gitignore
-rw-r--r-- 1 psteiner staff 2176 Jan 5 16:52 README.md
drwxr-xr-x 3 psteiner staff 102 Jan 5 16:52 configuration
-rw-r--r-- 1 psteiner staff 9345 Jan 5 16:52 pom.xml
-rw-r--r-- 1 psteiner staff 9223 Jan 5 16:52 quickstart-template.json
drwxr-xr-x 5 psteiner staff 170 Jan 5 16:52 src

Step 5: Push code to git repository

As explained earlier, the builder images for S2I expect the code to be in a git repo, so lets update the one we cloned earlier.

MacBook-Pro:Demos psteiner$ cd fuse_xpaas_demo/
MacBook-Pro:fuse_xpaas_demo psteiner$ git add *
MacBook-Pro:fuse_xpaas_demo psteiner$ git commit -m "initial"
[master 314458d] initial
 3 files changed, 52 insertions(+), 79 deletions(-)
MacBook-Pro:fuse_xpaas_demo psteiner$ git push
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 1.92 KiB | 0 bytes/s, done.
Total 5 (delta 3), reused 0 (delta 0)
To https://github.com/PatrickSteiner/fuse_xpaas_demo.git
 876d57b..314458d master -> master

Step 6: Create application template

During “Step 4” we did not only create the required code, but also a OpenShift template for the later application. So let’s import this one into our project.

MacBook-Pro:fuse_xpaas_demo psteiner$ oc create -f quickstart-template.json
template "s2i-quickstart-karaf-camel-log" created

 

Step 7: Create application

Now it’s time to change to the Web-UI of Openshift. Please make sure that you are in the right project before you click ‘Add to Project’

2016-01-05_17-03-57

We can now create an OpenShift application based on our created application template. If the list of available templates should be to long, simply setting the filter to ‘s2i’.

2016-01-05_17-04-49

As stated above, the builder image expects the code to reside in a git repository, so we have to tell him in which one. Do yourself a favour and don’t make the same mistake I did, trying to clone a private github.com repo … that doesn’t work 😉

2016-01-05_18-28-14

 

You should also not forget to let the template know where the builder images are created in. Remember step 3?

2016-01-05_17-06-27

Last, but not least … create the application

2016-01-05_17-06-46

Assuming you know your way around in OpenShift, you can now look at the logs of the builder and follow the build procedure!

, , , , , , , ,
5 comments on “First Fuse application on OpenShift V3.1
  1. Seems like the jar files are no longer available to perform these steps. Any ideas?

    11: https://repo.fusesource.com/nexus/content/groups/public/io/fabric8/archetypes/archetypes-catalog/2.2.0.redhat-079/archetypes-catalog-2.2.0.redhat-079-archetype-catalog.xml -> io.fabric8.archetypes:karaf-camel-log-archetype (Creates a new Camel Log Example)
    Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 11
    Downloading: https://repo.fusesource.com/nexus/content/groups/public/io/fabric8/archetypes/archetypes-catalog/2.2.0.redhat-079/io/fabric8/archetypes/karaf-camel-log-archetype/2.2.0.redhat-079/karaf-camel-log-archetype-2.2.0.redhat-079.jar
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 5.073 s
    [INFO] Finished at: 2016-07-28T11:38:45-04:00
    [INFO] Final Memory: 15M/146M
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:generate (default-cli) on project standalone-pom: The desired archetype does not exist (io.fabric8.archetypes:karaf-camel-log-archetype:2.2.0.redhat-079) -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

    • Hi Marc,

      thanks for pointing this out. Will have a look, but very short on time for the next two weeks.

      Patrick

  2. Hi Patrick

    All went well as per the steps you mentioned, followed exactly in the same you mentioned.

    However, when going to build, It is returning below logs at and breaks-

    Starting S2I Karaf Build …..
    Copying binary assembly from /tmp/src/deployments to /deployments …
    Please specify an existing build directory ARTIFACT_DIR (tried ‘/tmp/src/deployments’ which does not exist)
    I0824 03:29:45.372542 1 cleanup.go:23] Removing temporary directory /tmp/s2i-build002704331
    I0824 03:29:45.372609 1 fs.go:156] Removing directory ‘/tmp/s2i-build002704331’
    F0824 03:29:45.375735 1 builder.go:204] Error: build error: non-zero (13) exit code from registry.access.redhat.com/jboss-fuse-6/fis-karaf-openshift:latest

    Can you please suggest what could be wrong. It is giving error for $ATRIFACT_DIR, I am not sure how to set it, where it is etc.

    Thanks,
    Trilok

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: