Deploy Spring Cloud Config
This document shows how to deploy Spring Cloud Config in a Kf cluster.
Spring Cloud Config provides a way to decouple application code from its runtime configuration. The Spring Cloud Config configuration server can read configuration files from Git repositories, the local filesystem, HashiCorp Vault servers, or Cloud Foundry CredHub. Once the configuration server has read the configuration, it can format and serve that configuration as YAML, Java Properties, or JSON over HTTP.
Before you begin
You will need a cluster with Kf installed and access to the Kf CLI.
Additionally, you will need the following software:
git
: Git is required to clone a repository.
Download the Spring Cloud Config configuration server
To download the configuration server source:
Open a terminal.
Clone the source for the configuration server:
git clone --depth 1 "https://github.com/google/kf"
Configure and deploy a configuration server
To update the settings for the instance:
Change directory to
spring-cloud-config-server
:cd kf/spring-cloud-config-server
Open
manifest.yaml
.Change the
GIT_URI
environment variable to the URI of your Git configuration server.Optionally, change the name of the application in the manifest.
Optionally, configure additional properties or alternative property sources by editing
src/main/resources/application.properties
.Deploy the configuration server without an external route. If you changed the name of the application in the manifest, update it here:
kf push --no-route spring-cloud-config
Bind applications to the configuration server
You can create a user provided service to bind the deployed configuration server to other Kf applications in the same cluster or namespace.
How you configure them will depend on the library you use:
- Applications using Pivotal’s Spring Cloud services client library
Existing PCF applications that use Pivotal’s Spring Cloud Services client library can be bound using the following method:
Create a user provided service named config-server. This step only has to be done once per configuration server:
kf cups config-server -p '{"uri":"http://spring-cloud-config"}' -t configuration
For each application that needs get credentials, run:
kf bind-service application-name config-server kf restart application-name
This will create an entry into the
VCAP_SERVICES
environment variable for the configuration server.
- Other applications
Applications that can connect directly to a Spring Cloud Config configuration server should be configured to access it using its cluster internal URI:
http://spring-cloud-config
- For Spring applications that use the Spring Cloud Config client library
can set the
spring.cloud.config.uri
property in the appropriate location for your application. This is usually anapplication.properties
orapplication.yaml
file. - For other frameworks, see your library’s reference information.
Delete the configuration server
To remove a configuration server:
Remove all bindings to the configuration server running the following commands for each bound application:
kf unbind-service application-name config-server kf restart application-name
Remove the service entry for the configuration server:
kf delete-service config-server
Delete the configuration server application:
kf delete spring-cloud-config
What’s next
- Read more about the types of configuration sources Spring Cloud Config supports.
- Learn about the structure of the
VCAP_SERVICES
environment variable to understand how it can be used for service discovery.