Over a million developers have joined DZone.

Fuse Fabric Profile Migration for Continuous Delivery

· DevOps Zone

Discover how to optimize your DevOps workflows with our cloud-based automated testing infrastructure, brought to you in partnership with Sauce Labs

JBoss Fuse is a powerful distributed integration platform with built in features for centralized configuration management, service discovery, versioning, API gateway, load balancing, failover, etc for your integration-focused microservice deployments. JBoss Fuse 6.x is built on top of the Fabric8 1.x opensource project. This blog post shows how to use the powerful automation already built into Fuse to build up a migration path for your applications to achieve continuous delivery if so desired.

There is a sample project that this blog refers to https://github.com/christian-posta/fuse-fabric-promotion-build

What Fabric8 brings to the automation process

Fabric8 1.x brings a simple runtime grouping and provisioning model to allow you to quickly deploy and upgrade/downgrade your applications from a central dashboard/console across a fleet of machines. For this, you don’t need to have any custom scripting/ansible/chef/puppet automation as the automation comes out of the box with Fuse/Fabric8.

The central concept is a set of text-based properties files called profiles that declaratively describe the end-state of a deployment – i.e., they describe what binaries, features, configurations, dependencies, etc that need to be deployed together. Profiles are versioned (to allow for rolling upgrades) and can have hierarchy relationships to cut down on duplication of configurations.

The Problem

In a shared environment where you have multiple teams working on different integrations/microservices/applications that each have their own timelines, deployment cycle, or pre-existing continuous integration cycles, deploying into a shared environment can result in collisions. We have to establish a convention for how applications make it into this environment, and be able to automate it/version it. One of the tenants of Continuous Delivery is to version everything, including application configuration, environment configuration, automation scripts, etc. so that environments can be recreated on the fly if necessary and avoid highly manually tailored environments which end up becoming very brittle and risky.

With Fuse/Fabric8 profiles, everything is versioned in the built-in configuration management backend of Fuse/Fabric8, but how can those be recreated or how can those profiles be deployed into Fuse when applications change? And how can we do this within the constraints of applications deploying at different rates, different versions, different cycles, etc?

The Solution

A lot of automation is built into Fabric8 and this guide will attempt to show you how to best leverage it. Once you see what can be automated you’ll say “ah, so I don’t need all of these other scripts/tools to do this”? Let’s take a step-by-step look. The focus of this guide will be fabric8 1.x, but more specifically JBoss Fuse Fabric 6.1 or 6.2. Some of the out-of-the-box features (I’ll point them out along the way) are only available in the Fuse 6.2 versions, but can still be accomplished with the Fuse 6.1 environment (although, with some scripting)


Fuse 6.1/6.2

The fabric8-maven-plugincomes out of the box with Fuse 6.1. It plugins into your maven maven lifecycle with a few configuration lines in your project’s pom.xml. It provides a single goal (next section) in Fuse 6.1 and adds additional goals in Fuse 6.2.

Automate creating profiles

Fuse 6.1/6.2

If you take a look at the example projects/modules in this repo (the EIP module or the REST module) you’ll see that the pom.xml has a <build> section that configures the fabric8-maven-plugin. For example, in the REST module:

02.    <groupId>io.fabric8</groupId>
03.    <artifactId>fabric8-maven-plugin</artifactId>
04.    <version>${fabric8.maven.plugin.version}</version>
05.    <configuration>
06.        <profile>my-rest</profile>
07.        <features>fabric-cxf-registry fabric-cxf cxf war swagger</features>
08.        <featureRepos>mvn:org.apache.cxf.karaf/apache-cxf/${version:cxf}/xml/features</featureRepos>
09.    </configuration>

This will automatically create the fabric8 profiles for this project. If you run mvn fabric8:deploy it will install the profiles into a locally running fabric8. This is a very useful development-time goal to test that profiles get created correctly. (Note, you have to have your ~/.m2/settings.xml file set up correctly to have the un/pw for your fabric server. by default the server id it will look for is fabric8.upload.repo)

Automatically archiving your profiles

Fuse 6.2

02.    <groupId>io.fabric8</groupId>
03.    <artifactId>fabric8-maven-plugin</artifactId>
04.    <version>${fabric8.maven.plugin.version}</version>
05.    <configuration>
06.        <profile>my-rest</profile>
07.        <features>fabric-cxf-registry fabric-cxf cxf war swagger</features>
08.        <featureRepos>mvn:org.apache.cxf.karaf/apache-cxf/${version:cxf}/xml/features</featureRepos>
09.    </configuration>
10.        <executions>
11.            <execution>
12.                <id>fabric8-zip</id>
13.                <phase>
14.                    package
15.                </phase>
16.                <goals>
17.                    <goal>zip</goal>
18.                </goals>
19.            </execution>
20.        </executions>

With this configuration, you will also notice that by default the zip goal will be attached to the package phase of the build. This is only available in Fuse 6.2 version of the plugin (see the versions used in this project). The zip goal will produce the profiles and zip them up into a single distribution that can be uploaded to a maven repository. So for example, as part of a a step in your Continuous Integration processes, you can have this zip created and pushed into your maven repository along with the binaries for your project. So this way you have both the binaries and the Fabric profiles deployed into on single artifact repository. For example, if you run mvn clean install from the root of the REST module in this project, you can see the profile zips in the ./target folder as well as the corresponding location under ~/.m2/repository

Independent versioning

In your environment you may have multiple applications and deployments. Each will have its own version number and lifecycle. Fuse also has versioning built around profiles for deploying updated applications or downgrading applications. Fuse Fabric has these two concepts for versioning of profiles:

  • Version sets
  • Git backed change management

When we deploy our applications, we need to line up the various independent application versions with a Fuse Fabric version set. So for example, in our project, we have the EIP project and the REST project. The EIP project is versioned with 2.0 and the REST project is versioned with 1.5. So how do we bring in these two versions of the applications and their profiles into Fabric?

Environment build

Fuse 6.2

We use a single environment build to aggregate the separate projects that will have profiles that need to be added to the Fuse Fabric registry. If you look at the environment-build project’s pom.xml file you’ll see something like this:

02.    <groupId>com.redhat.demo.promotion</groupId>
03.    <artifactId>eip</artifactId>
04.    <version>2.0</version>
05.    <type>zip</type>
06.    <classifier>profile</classifier>
09.    <groupId>com.redhat.demo.promotion</groupId>
10.    <artifactId>rest</artifactId>
11.    <version>1.5</version>
12.    <type>zip</type>
13.    <classifier>profile</classifier>

You can see the different profiles that make up the disparate applications are added as dependencies and they’re zip files that are classified as “profile” which will be looked up in the maven repository. So if you used the zip goal from above, and installed the profiles into your maven repository, you can then refer to them in the environment build like above.

The key here is that the fabric8-maven-plugin has a goal called branch that will do the following:

  • Connect to an existing Fuse Fabric git repo and clone the existing branch into a new branch
  • Grab the above zip dependencies from maven
  • Unzip and merge the new profiles into the fabric git repo
  • Commit the changes
  • Optionally push the new branch back up to Fabric

This requires Fuse 6.2 fabric8-maven-plugin, but works against an existing Fuse 6.1 or Fuse 6.2 installation.

The configuration for the branch goal looks like this:

02.    <groupId>io.fabric8</groupId>
03.    <artifactId>fabric8-maven-plugin</artifactId>
04.    <version>${fabric8.maven.plugin.version}</version>
05.    <executions>
06.        <execution>
07.            <id>branch</id>
08.            <phase>compile</phase>
09.            <goals>
10.                <goal>branch</goal>
11.            </goals>
12.            <configuration>
13.                <!-- lets choose the name of the version in the git repository where we will create the branch -->
14.                <branchName>1.0.1</branchName>
15.                <gitUrl>http://admin:admin@postamac.local:8181/git/fabric</gitUrl>
16.                <oldBranchName>1.0</oldBranchName>
17.                <pushOnSuccess>true</pushOnSuccess>
18.            </configuration>
19.        </execution>
20.    </executions>

You specify in the pom.xml (or on the command line) what the branchName (new branch) and whether to pushOnSuccess. If you point to an existing running fuse, and run:

1.mvn compile

Fuse should automatically do the above steps and push the profiles as expected.

NOTE: I’ve just recently committed some fixes to fabric8 to allow things to work as described as there were a few bugs previously. Please wait for next early releases of Fuse 6.2 to take advantage of these features as described here

For more Fabric8, JBoss Fuse, ActiveMQ, Camel, Microservices, Cloud, etc follow me on twitter @christianposta or my blog http://blog.christianposta.com

Download “The DevOps Journey - From Waterfall to Continuous Delivery” to learn learn about the importance of integrating automated testing into the DevOps workflow, brought to you in partnership with Sauce Labs.

devops ,fabric8 ,fuse ,continuous delivery ,enterprise-integration

Published at DZone with permission of Christian Posta, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}