Using Apache Karaf with Docker

2022-01-13 Thread Andrei Petru Mura
Hi everyone,

I have a dilemma which I'll present to you here. Any advice/indications?

Case 1. I have a production system in which I have multiple virtual
machines. In every such virtual machine I run an Apache Karaf instance. In
all this Apache Karaf instances (one per virtual machine) I run multiple
applications (deployed as OSGI bundles).

Case 2. I have a production system in which I have multiple virtual
machines. In every such virtual machine I run an Apache Karaf instance. In
all this Apache Karaf instances (one per virtual machine) I run only one
application (deployed as OSGI bundles).

N.B. The only difference between Case 1 and Case 2 is that in case 1 I have
multiple OSGI bundles in Karaf, while in case 2 I have only one OSGI bundle
in Karaf (along the libraries).

Question:
Is it OK for case 1 or case 2 to be dockerized? This means, instead of
running multiple VMs, I'll run multiple docker containers.

Thanks,
Andrei Mura


Re: Using Apache Karaf with Docker

2022-01-13 Thread Jean-Baptiste Onofré

Hi Andrei,

Both cases work with Docker, maybe case 1 is "more" interesting (but it 
depends of your provisioning scenario).


Regards
JB

On 13/01/2022 11:19, Andrei Petru Mura wrote:

Hi everyone,

I have a dilemma which I'll present to you here. Any advice/indications?

Case 1. I have a production system in which I have multiple virtual 
machines. In every such virtual machine I run an Apache Karaf instance. 
In all this Apache Karaf instances (one per virtual machine) I run 
multiple applications (deployed as OSGI bundles).


Case 2. I have a production system in which I have multiple virtual 
machines. In every such virtual machine I run an Apache Karaf instance. 
In all this Apache Karaf instances (one per virtual machine) I run only 
one application (deployed as OSGI bundles).


N.B. The only difference between Case 1 and Case 2 is that in case 1 I 
have multiple OSGI bundles in Karaf, while in case 2 I have only one 
OSGI bundle in Karaf (along the libraries).


Question:
Is it OK for case 1 or case 2 to be dockerized? This means, instead of 
running multiple VMs, I'll run multiple docker containers.


Thanks,
Andrei Mura


Re: Using Apache Karaf with Docker

2022-01-13 Thread Steinar Bang
> Jean-Baptiste Onofré :

> Both cases work with Docker, maybe case 1 is "more" interesting (but
> it depends of your provisioning scenario).

@Andrei, as JB hints at there are many ways to dockerize karaf
applications.

My applications are provisioned by creating karaf features and deploy
OSGi bundles and karaf features to a maven repository, and then load the
features in karaf.

So for docker, what I've done is to start with the standard karaf docker
image deployed to dockerhub, and then override the file
etc/org.apache.karaf.features.cfg in the karaf installation in the
docker image, with a file that loads the LATEST version my feature(s).

I also deploy versions of the JDBC Config files of my application, that
can have the URL and USERNAME/PASSWORD values set from environment
variables, making them easy to set in the deploy.

That means that when I deploy my image it can provision from the newest
deploy to maven, without me having to build a new docker image.

Here's an example of a maven module that builds a docker image on top of
the standard karaf docker image:
 https://github.com/steinarb/sonar-collector/tree/master/docker

Caveat emptor! I haven't run this for a while so it may not be working
right now (I probably have to update the docker image version to a newer
karaf version).

FWIW My deployment model is to have a single karaf instance in my VPS,
deploying all of my applications as OSGi bundles.

Works like a charm for me!