Skip to content

Latest commit

 

History

History
105 lines (74 loc) · 4.53 KB

README.md

File metadata and controls

105 lines (74 loc) · 4.53 KB

Steeltoe app + Config Server

This repo uses code from Steeltoe Samples to demonstrate deploying your own Config Server to Cloud Foundry and connecting it to your Steeltoe application. Additionally, it documents examples of fetching configuration Config Server.

Deploy your app

cd SimpleCloudFoundry
cf push --hostname <unique-app-hostname>

Deploy our own Config Server

cd configserver
./mvnw package -Dmaven.test.skip=true
cf push config-server -p target/configserver-0.0.1-SNAPSHOT.jar --hostname <unique-config-server-hostname>

Point app at Config Server

http://steeltoe.io/docs/steeltoe-configuration/#2-2-2-configure-settings

Only two settings are really necessary. spring:application:name configures the "application name" to be sample, and spring:cloud:config:uri the address of the config server.

The application name is already configured in the appsettings.json, so we only need to override the config server uri. When translated into environment variables, spring:cloud:config:uri turns into spring__cloud__config__uri. Note the double underscores (__) which denote hierarchy. So to point a Steeltoe application to our own Config Server, we need to set the environment in Cloud Foundry and restart the application.

cf set-env foo spring__cloud__config__uri https://<unique-config-server-hostname>.cfapps.io
cf restart foo

Querying Config Server

Configuration can be queried from Config Server via combination of application, profile, and label.

  • label - in the case of Config Server backed by git, this is a branch, tag, or commit sha
  • application - name of application requesting the configuration
  • profile - a grouping of configuration, which can be used to provide different configuration based on environment such as "dev", "test", "qa", "production"
/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.yml
/{label}/{application}-{profile}.properties

Configuration can be accessed in the YAML or properties format, as well as via a JSON payload that returns configuration along with some metadata (i.e. matched application name, property source, etc).

Examples

The examples below use Config Server deployed with a hostname of "my-config-server". Adjust the urls to match your own deployment.