Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document howto share common properties for a subset of services #618

Open
rmotapar opened this issue Jan 26, 2017 · 7 comments
Open

Document howto share common properties for a subset of services #618

rmotapar opened this issue Jan 26, 2017 · 7 comments

Comments

@rmotapar
Copy link

We have several micro-services in our project that use the same config server (same git repository). Any common properties that are needed by more than one service/module are being placed in application.properties. So if serviceA and serviceB need a property, it will be placed in application.properties. But the problem is that this property will be available to rest of the services as well. This makes it harder for the dev ops team to configure the application.properties as they need to understand which specific properties apply to a particular service. For better manageability, we would also like to store these properties in separate files and have services load them up via config server.

So my questions are:
Is there any way we can share a common set of properties among a subset of services (and not all of them) without polluting the base application.properties? Is it possible to define multiple base files for a service? For example,

I would like to have multiple base property files like below:
application.properties
application-prod.properties
cassandra.properties
cassandra-prod.properties
jpa.properties
jpa-prod.properties
redis.properties
redis-prod.properties
async.properties
async-prod.properties

And configure a service to use just the property files that it needs. So serviceA and serviceB which use cassandra can be configured to use application.properties and cassandra.properties whereas ServiceC which needs jpa will be configured to use application.properties and jpa.properties

Please let me know if something like above is possible and if there are any approaches that might help in our case. Thanks in advance for any help/suggestions you can provide

@spencergibb
Copy link
Member

Use profiles? At the very least application-cassandraprod.properties. I'm checking with the boot team to see if you can qualify with multiple profiles.

We use the boot mechanisms to load these files, so we don't want to stray from that.

@spencergibb
Copy link
Member

The only special file in configserver is application.{yml|properties}, everything else is based off the application name passed in.

@spencergibb
Copy link
Member

spencergibb commented Jan 26, 2017

You could set, on the client side, spring.cloud.config.name=${spring.application.name},cassandra, and the profile prod, then it would pick up (if spring.application.name=foo): foo.properties, foo-prod.properties, cassandra.properties and cassandra-prod.properties.

That looks like it will work.

@rmotapar
Copy link
Author

That's very good to know. I will test this and confirm the results soon. Thank you @spencergibb

@spencergibb
Copy link
Member

Might be nice to add to the docs.

@rmotapar
Copy link
Author

@spencergibb It is working as you described. Thank you very much! One thing I noticed is that the order of the names defined under spring.cloud.config.name matters. That is, if spring.application.name=cassandra,servicea then properties in servicea.properties file override any matching properties in cassandra.properties

@spencergibb
Copy link
Member

spencergibb commented Jan 26, 2017

Noted on ordering. That is because that is how the properties are ordered coming back from config server, so it does make sense to me.

@spencergibb spencergibb changed the title Share common properties for a subset of services Document howto share common properties for a subset of services Jan 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants