Deploy Spring Cloud Config

Learn how to deploy Spring Cloud Config as a configuration server.

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:

  1. Open a terminal.

  2. 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:

  1. Change directory to spring-cloud-config-server:

    cd kf/spring-cloud-config-server
    
  2. Open manifest.yaml.

  3. Change the GIT_URI environment variable to the URI of your Git configuration server.

  4. Optionally, change the name of the application in the manifest.

  5. Optionally, configure additional properties or alternative property sources by editing src/main/resources/application.properties.

  6. 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:

  1. 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
    
  2. 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 an application.properties or application.yaml file.
  • For other frameworks, see your library’s reference information.

Delete the configuration server

To remove a configuration server:

  1. 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
    
  2. Remove the service entry for the configuration server:

    kf delete-service config-server
    
  3. Delete the configuration server application:

    kf delete spring-cloud-config
    

What’s next