You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Cantbebotheredtothinkofauserna <Bo...@outlook.com> on 2019/02/01 13:59:52 UTC

Deploy karaf 4.2.2 to multiple envs with different configurations

I'm building a 4.2.2 custom distribution which is to be deployed to multiple
environments. Each env should have it's own config, but shouldn't know about
other env's configs. I wanted to use Karaf profiles but there isn't any
documentation on it, and I'm not sure if itll abide by the "no env should
know about other envs config" rule.

What's the best approach in this case? Ideally I'd like to have a config
file (containting values for things like http port) placed in each env then
picked up by Karaf when launched (before the bundles start up). The config
files in each env would have the same relative path from the karaf assembly. 



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Deploy karaf 4.2.2 to multiple envs with different configurations

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
It would be the same, you will be able to apply a profile setting the
properties, but you would have to restart anyway.

As the system.properties is equivalent of doing java -Dfoo=bar, you have
to restart the JVM (that's not Karaf specific, it's the way it works in
Java).
If your application uses env or ConfigAdmin, that would be different.

Regards
JB

On 01/02/2019 17:34, Cantbebotheredtothinkofauserna wrote:
> Yes these properties need to be in system.properties since one of our core
> applications gets them via System.getProperty("..."). 
> 
> Is this something that can be achieved using profiles? 
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Deploy karaf 4.2.2 to multiple envs with different configurations

Posted by Cantbebotheredtothinkofauserna <Bo...@outlook.com>.
Yes these properties need to be in system.properties since one of our core
applications gets them via System.getProperty("..."). 

Is this something that can be achieved using profiles? 



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Deploy karaf 4.2.2 to multiple envs with different configurations

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
That's normal: the system.properties are loaded by Karaf Main, before
any other service (including ConfigAdmin).

Do you really need system properties there ?

Regards
JB

On 01/02/2019 17:11, Cantbebotheredtothinkofauserna wrote:
> I'm trying to add system properties via
> 
> <feature name="env-config">
>   <configfile finalname="etc/custom.system.properties"
> override="true">file:${env.config.path}/custom.system.properties</configfile>
> </feature>
> 
>  This file gets updated but I have to restart karat for the properties to
> actually get picked up. I have this as a startup feature - I guess even at
> this stage it's too late for the properties to get registered?
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Deploy karaf 4.2.2 to multiple envs with different configurations

Posted by Cantbebotheredtothinkofauserna <Bo...@outlook.com>.
I'm trying to add system properties via

<feature name="env-config">
  <configfile finalname="etc/custom.system.properties"
override="true">file:${env.config.path}/custom.system.properties</configfile>
</feature>

 This file gets updated but I have to restart karat for the properties to
actually get picked up. I have this as a startup feature - I guess even at
this stage it's too late for the properties to get registered?



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Deploy karaf 4.2.2 to multiple envs with different configurations

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
feature works with any file and provisioning.

For instance, you can do:

<feature name="uat-env" version="1.0-SNAPSHOT">
  <configfile
finalname="etc/foo.cfg">mvn:groupId/artifactId/1.0-SNAPSHOT/uat/cfg</configfile>
  <configfile
finalname="deploy/foo.xml">mvn:groupId/artifactId-foo/1.0-SNAPSHOT/uat/xml</configfile>
</feature>

<feature name="qa-env" version="1.0-SNAPSHOT">
  <configfile
finalname="etc/foo.cfg">mvn:groupId/artifactId/1.0-SNAPSHOT/qa/cfg</configfile>
  <configfile
finalname="deploy/foo.xml">mvn:groupId/artifactId-foo/1.0-SNAPSHOT/qa/xml</configfile>
</feature>

Regards
JB

On 01/02/2019 16:10, Cantbebotheredtothinkofauserna wrote:
> Hi, does the feature approach only work for cfg files? What about .properties
> files?
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Deploy karaf 4.2.2 to multiple envs with different configurations

Posted by Cantbebotheredtothinkofauserna <Bo...@outlook.com>.
Hi, does the feature approach only work for cfg files? What about .properties
files?



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Deploy karaf 4.2.2 to multiple envs with different configurations

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Before talking about profile (that could be used there), you can also
create env specific feature just containing the config.

For the profile, you can take a look on the example:

https://github.com/apache/karaf/tree/master/examples/karaf-profile-example

I'm planning to blog and update the documentation with profile use case.

Regards
JB

On 01/02/2019 14:59, Cantbebotheredtothinkofauserna wrote:
> I'm building a 4.2.2 custom distribution which is to be deployed to multiple
> environments. Each env should have it's own config, but shouldn't know about
> other env's configs. I wanted to use Karaf profiles but there isn't any
> documentation on it, and I'm not sure if itll abide by the "no env should
> know about other envs config" rule.
> 
> What's the best approach in this case? Ideally I'd like to have a config
> file (containting values for things like http port) placed in each env then
> picked up by Karaf when launched (before the bundles start up). The config
> files in each env would have the same relative path from the karaf assembly. 
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com