LATEST VERSION: 3.0 - RELEASE NOTES
Spring Cloud Services v3.0

Managing Service Instances

Page last updated:

See below for information about managing Config Server service instances using the Cloud Foundry Command Line Interface tool (cf CLI). You can also manage Config Server service instances using Pivotal Cloud Foundry® Apps Manager.

Creating an Instance

Begin by targeting the correct org and space.

$ cf target -o myorg -s development

You can view plan details for the Config Server product using cf marketplace -s.

$ cf marketplace -s p.config-server
Getting service plan information for service p.config-server as user...
OK

service plan   description       free or paid
standard       A standard plan   free

Create the service instance using cf create-service, using the -c flag to provide a JSON object that specifies the configuration parameters. For information about the parameters used to configure a Git backend, see Configuring with Git. For information about the parameters used to configure a HashiCorp Vault backend, see Configuring with Vault.

General parameters accepted for the Config Server are listed below.

Parameter Function Example
count The number of nodes to provision: 1 by default, more for running in high-availability mode '{"count": 3}'

To create an instance, specifying settings for a Git backend and that three nodes should be provisioned:

$ cf create-service -c '{ "git": { "uri": "https://github.com/spring-cloud-samples/config-repo" }, "count": 3 }' p.config-server standard config-server

You can use the cf services or cf service commands to check the status of the service instance. When the service instance is ready, the cf service command will give a status of create succeeded:

$ cf service config-server
Showing info of service config-server in org myorg / space dev as user...

name:            config-server
service:         p.config-server
tags:
plan:            standard
[...]

Showing status of last operation from service config-server...

status:    create succeeded

Important: The cf service and cf services commands may report a create succeeded status even if the Config Server cannot initialize using the provided settings. For example, given an invalid URI for a Git backend, the service instance may still be created and have a create succeeded status.

Updating an Instance

You can update settings on a Config Server service instance using the Cloud Foundry Command Line Interface tool (cf CLI). The cf update-service command can be given a -c flag with a JSON object containing parameters used to configure the service instance.

To update a Config Server service instance’s settings, target the org and space of the service instance:

$ cf target -o myorg -s development

Then run cf update-service SERVICE_NAME -c '{ "PARAMETER": "VALUE" }', where SERVICE_NAME is the name of the service instance, PARAMETER is a supported parameter, and VALUE is the value for the parameter. For information about the parameters used to configure a Git backend, see Configuring with Git. For information about the parameters used to configure a HashiCorp Vault backend, see Configuring with Vault.

General parameters accepted for the Config Server are listed below.

Parameter Function Example
count The number of nodes to provision: 1 by default, more for running in high-availability mode '{"count": 3}'

To update a service instance, configuring a Git backend, run:

$ cf update-service config-server -c '{"git": { "uri": "https://github.com/spring-cloud-samples/config-repo" } }'

To update a service instance and set the count of instances for running in high-availability mode, run:

$ cf update-service config-server -c '{"count": 3}'

You can use the cf services or cf service commands to check the status of the service instance. When the update is complete, the cf service command will give a status of update succeeded:

$ cf service config-server
Showing info of service config-server in org myorg / space dev as user...

name:            config-server
service:         p.config-server
tags:
plan:            standard
[...]

Showing status of last operation from service config-server...

status:    update succeeded

Important: The cf service and cf services commands may report an update succeeded status even if the Config Server cannot initialize using the provided settings. For example, given an invalid URI for a Git backend, the service instance may still be restarted and have an update succeeded status.

The service instance is now updated and ready to be used. For information about using an app to access configuration values served by a Config Server service instance, see Writing Client Applications.

Refreshing an Instance’s Mirrors

The Config Server backing app uses Spring Boot Actuator. You can refresh Git mirrors used by a Config Server service instance by invoking the Actuator refresh endpoint, available at the path /actuator/refresh using (for example) cURL. To invoke this endpoint, you must supply an OAuth 2.0 bearer token.

Note: The following procedure uses the jq command-line JSON processing tool.

To update Git mirrors for a Config Server service instance named “cook-config-server”, create a service key for the service instance:

$ cf create-service-key cook-config-server cook-config-server-key
Creating service key cook-config-server-key for service instance cook-config-server as user...
OK

Then read the service key’s properties using the cf service-key command:

$ cf service-key cook-config-server cook-config-server-key
Getting key cook-config-server-key for service instance cook-config-server as user...

{
 "access_token_uri": "https://uaa.system.example.com:443/oauth/token",
 "client_id": "config-client-44e03aab-6328-4fcb-81cd-2acb559c8dd2",
 "client_secret": "d0hh9ubg24lb0",
 "uri": "https://config-server-d3421ad5-5f7c-4998-889f-76623d21f602.apps.example.com"
}

Finally, run the following Bash script, which fetches a token and then uses it with cURL to make an HTTP POST request to the Actuator refresh endpoint:

$ TOKEN=$(curl -k [ACCESS_TOKEN_URI] -u [CLIENT_ID]:[CLIENT_SECRET] -d grant_type=client_credentials | jq -r .access_token); curl -H "Authorization: bearer $TOKEN" -H "Content-Type: application/json" -X POST [URI]/actuator/refresh

In this script, replace the following placeholders with values from the cf service-key command:

  • [ACCESS_TOKEN_URI] with the value of access_token_uri
  • [CLIENT_ID] with the value of client_id
  • [CLIENT_SECRET] with the value of client_secret
  • [URI] with the value of uri
Create a pull request or raise an issue on the source for this page in GitHub