Posts

Load balancing with Apache Karaf Cellar, and mod_proxy_balancer

Thanks to Cellar, you can deploy your applications, CXF services, Camel routes, … on several Karaf nodes. When you use Cellar with web applications, or CXF/HTTP endpoints, a “classic” need is to load balance the HTTP requests on the Karaf nodes. You have different ways to do that: – using Camel Load Balancer EIP: it’s an interesting EIP, working with any kind of endpoints. However, it requires to have a Karaf running the Load Balancer routes, so it’s not always possible depending of the user security policy (for instance, putting it in DMZ or so) – using hardware appliances like F5, Juniper, Cisco: it’s a very good solution, “classic” solution in network teams. However, it requires expensive hardwares, not easy to buy and setup for test or “small” solution. – using Apache httpd with mod_proxy_balancer: it’s the solution that I’m going to detail. It’s a very stable solution, powerful and easy ...

Multiple HTTP connectors in Apache Karaf

Installing the http feature in Karaf leverages Pax Web to embed a Jetty webcontainer. By default, Karaf create a Jetty connector on the 8181 http port (and 8443 for https). You can change this port number by providing etc/org.ops4j.pax.web.cfg file. But, you can also create new connector in the embedded Jetty. You may see several advantages for multiple connectors: you can isolate a set of applications, CXF services, Camel routes on a dedicated port number you can setup a different configuration for each connector. For instance, you can create two SSL connectors, each with a different keystore, truststore, … You can find etc/jetty.xml configuration file where you can create custom Jetty configuration. NB: if you want to have both etc/org.ops4j.pax.web.cfg and etc/jetty.xmll, don’t forget to reference jetty.xml in org.ops4j.pax.web.cfg using the org.ops4j.pax.web.config.file property pointing to the jetty.xml, for instance: # in etc/org.ops4j.pax.web.cfg org.ops4j.pax.web.con...

Create custom log4j appender for Karaf and Pax Logging

Karaf leverages Pax Logging for the logging layer. Pax Logging provides an abstraction service for most popular logging frameworks, like SLF4J, Log4j, commons-logging, etc. Karaf provides a default logging configuration in etc/org.ops4j.pax.logging.cfg file. By default, all INFO log messages (rootLogger) are send into a file appender (in data/log/karaf.log). The file appender “maintains” one file of 1MB, and store up to 10 backup files. Adding a new appender configuration, example with Syslog appender We can add new appender configuration in the Karaf logging module. For instance, we can add a syslog appender in etc/org.ops4j.pax.logging.cfg: log4j.rootLogger = INFO, out, syslog, osgi:* ... # Syslog appender log4j.appender.syslog=org.apache.log4j.net.SyslogAppender log4j.appender.syslog.layout=org.apache.log4j.PatternLayout log4j.appender.syslog.layout.ConversionPattern=[%p] %c:%L - %m%n log4j.appender.syslog.syslogHost=localhost log4J.appender.syslog.facility=KARAF log4j.ap...

How to enable HTTPS certificate client auth with Karaf

I received many times messages from users asking how we can “trust” HTTP clients in Karaf. The purpose is to exchange certificates and allow only “trusted” clients to use the Karaf HTTP service. Enable HTTP client auth First of all, we have to enable the HTTP client auth support in Karaf. When you install the HTTP feature, Karaf leverages Pax-Web to provide HTTP OSGi service: karaf@root> features:install http Now, we have to add a custom etc/org.ops4j.pax.web.cfg file: org.osgi.service.http.port=8181 org.osgi.service.http.port.secure=8443 org.osgi.service.http.secure.enabled=true org.ops4j.pax.web.ssl.keystore=./etc/keystores/keystore.jks org.ops4j.pax.web.ssl.password=password org.ops4j.pax.web.ssl.keypassword=password #org.ops4j.pax.web.ssl.clientauthwanted=false org.ops4j.pax.web.ssl.clientauthneeded=true NB: clientauthwanted and clientauthneeded properties are valid for Karaf 2.2.x which use Pax Web 1.0.x. Thanks to the clientauthneeded property, we “fo...

Apache Karaf Cellar 2.2.5 released !

During the ApacheCon EU , I made a demo of Karaf and Cellar all together. During this demo, I used Cellar 2.2.5-SNAPSHOT. Now, Cellar 2.2.5 is released ! But, what’s new in this version ? Groups are now persistent In Cellar 2.2.4, the empty groups disappear after a restart. You created a new cluster group without any member (empty group) with: karaf@root> cluster:group-create foobar karaf@root> cluster:group-list|grep -i foobar foobar [] If you restart Cellar (or Karaf), the empty groups were lost: karaf@root> cluster:group-list|grep -i foobar To avoid this, in Cellar 2.2.5, the cluster groups are now persistent on each node. We introduced a new groups property in etc/org.apache.karaf.cellar.groups.cfg to store the list of groups. Cellar now reads this property as startup to populate the cluster groups not present on the cluster. On the other hand, the groups property in etc/org.apache.karaf.cellar.node.cfg defines the group membership of the local node. If you restart Kar...

Apache Karaf 2.3.0 released !

Waiting for Karaf 3.0.0, we worked hard in the Karaf team to provide Apache Karaf 2.3.0. The Karaf 2.2.x branch is now only in maintenance mode: it means that no new features will be implemented in this branch, only major bug fixes. The new “stable” branch is now Karaf 2.3.x which is a perfect transition branch between Karaf 2.2.x (heavely used) and the future Karaf 3.x (which should arrive very soon). What’s new in this 2.3.0 release: * OSGi r4.3 : Karaf 2.2.x branch was powered by OSGi frameworks implementing OSGi r4.2 norm. Karaf 2.3.0 is now powered by the new OSGi r4.3 framework (Apache Felix 4.0.3 and Equinox 3.8.x), for both OSGi core and compendium. It provides new features like weaving, etc. * Aries Blueprint 1.0.x : Karaf 2.3.0 uses the new Aries Blueprint version at different level (core, JMX, etc). * Update to ASM 4.0 : in order to work with Aries proxies, we updated to new ASM bundle. We also provided configuration that allows you to enable/disable weaving...

Apache Karaf 2.2.9

The Apache Karaf team is proud to announce a new version on the Karaf 2.2.x branch. The 2.2.9 version is a major bug fixes release. We fixed 52 issues in this release, and we are inline with our release cycle (around every 2 months). Especially, it includes: Work with the latest JRE/JDK 1.6.0 and 1.7.0 updates : some changes in the Java Virtual Machine resulted to issues in previous Karaf releases. It’s now fixed in Karaf 2.2.9, allowing Karaf to work with Java 1.6.0_33 or 34 for instance, but fixed in Karaf itself and an upgrade to Aries Proxy 0.3.1. New OSGi frameworks : this release upgrade to the latest minor versions of the OSGi frameworks, especially Apache Felix Framework 3.2.2. Dependencies minor version updates : in order to fix several minor issues, some dependencies have been upgraded (javax.mail 1.4.5, ServiceMix bundles, etc). Stopping the shell console doesn’t stop the OSGi framework : previously, when you stopped the Karaf shell console bundle, it also stopped...