EngineNew Features

Centralized configuration as Spring Cloud Config provider

For the new 5.1.0-Survivor release, we have created a new Onesait Platform library that allows you to integrate Spring Cloud Config  as a Centralized Platform Configuration.

To do this, you will use the Spring configuration for Custom Composite Environment Repositories, which will allow you to use your own SpringBoot bean to load the configuration.

Besides, centralized configuration management that was previously managed in the Java client, has been integrated into this library.

How to use the config-client library?

First of all, you will have to add the following dependency to the pom.xml of the project that will act as Config Server:

<dependency>
	<groupId>com.minsait.onesait.platform</groupId>
	<artifactId>onesaitplatform-spring-config-client</artifactId>
	<version>5.0.0</version>
</dependency>

Besides, you will have to add the Platform repository to the list of repositories within the pom:

<repositories>
	<repository>
		<id>onesait platform releases</id>
		<url>https://nexus.onesaitplatform.com/nexus/content/repositories/releases/</url>
	</repository>
</repositories>

Once the dependency is added, you will need to add the following properties to your application.yml:

spring:
  profiles:
    active: native
  cloud:
    config:
      server:
        native:
          search-locations: classpath:/configuration
          order: 1
onesaitplatform:
  api.rest:
    token: <ONESAITPLATFORM_API_KEY> 
    endpoint: <ONESAITPLATFORM_BASE_URL>
  spring.cloud.config:
    enabled: true
    identification: <ONESAITPLATFORM_CONFIG>

Where:

  • ONESAITPLATFORM_API_KEY: is the API Key of a user with Platform administrator role. This key will be used to manage security at the Platform level, in order to obtain centralized configuration.
  • ONESAITPLATFORM_BASE_URL: is the endpoint of the Platform Control Panel, where the centralized configuration you want to use is located.
  • ONESAITPLATFORM_CONFIG: is the name of the centralized configuration you want to use.

Once your project is configured, when you start it, it will access the Platform and get the properties loaded in the specified centralized configuration.

Header image: Sigmund at Unsplash.

✍🏻 Author(s)

Leave a Reply