For Spring Cloud Services configuration, when you make a change to a configuration property stored in a Git repository, you may need to update both the mirror used by the Config Server and the client application's local configuration. Here you will find information about refreshing configuration properties served by a Config Server service instance.

Note In Spring Cloud Services v3.1.2 and later, you can use the periodic parameter when configuring a Config Server service instance to cause the mirror service to automatically refresh a Git repository mirror periodically. See the General Configuration section of Configuring with Git.

Config server architecture

The Config Server serves properties from multiple sources, including one or more Git repositories. For Git repositories, the Config Server makes use of an internal "mirror service" to create a mirror of each Git repository used. These mirrors are local to the VMware Tanzu Application Service for VMs (TAS for VMs) foundation, and the Config Server serves properties to client applications from these mirrors, rather than from the external Git repositories themselves.

Git to Mirror Service, to Config Server, to Config Clients

Refreshing Git mirrors

You can manually refresh a Config Server service instance's Git mirrors using Apps Manager, the Cloud Foundry Command Line Interface (cf CLI), or a custom Spring Boot Actuator endpoint on the service instance's backing app.

Using the dashboard

Note The Synchronize Mirrors button is available only in Spring Cloud Services v3.0.3 and later.

To refresh a Config Server service instance's Git mirrors using the dashboard, locate the service instance's dashboard as described in Using the Dashboard.

Spring Cloud Services, SCS Config Server Configuration

Below the Configuration section, click Synchronize Mirrors. When the mirror has been updated, the dashboard will display the message "Mirror refresh complete."

Using the cf CLI

To use the Spring Cloud Services cf CLI plug-in to refresh Git mirrors for a service instance, you must have either the Space Developer role in the service instance's space, or the Admin role.

To refresh a Config Server service instance's Git mirrors using the cf CLI, you can use the cf config-server-sync-mirrors command added by the Spring Cloud Services plug-in for the cf CLI (see Cloud Foundry CLI Plugin). For example, to refresh the Git mirrors for a Config Server service instance named my-config-server, you would run:

$ cf config-server-sync-mirrors my-config-server

You can also use the cf update-service command to refresh Git mirrors for a service instance, by passing an update-git-repos parameter to the command. This parameter forces the Config Server mirror service to pull all upstream Git repositories used by a Config Server service instance.

To update all mirrors used by a Config Server service instance, run cf update-service SERVICE_NAME -c '{ "update-git-repos": true }', as in the following example:

$ cf update-service my-config-server -c '{"update-git-repos": true }'

When the mirror has been updated, the cf service SERVICE_NAME command will give a status of update succeeded.

Using the Actuator endpoint

To use this method of refreshing Git mirrors for a service instance, you must have either the Space Developer role in the service instance's space, or the Admin role.

Each Config Server service instance has a custom Spring Boot Actuator endpoint available at /actuator/refreshmirrors. You can use this endpoint to refresh a Config Server service instance's Git mirrors.

After locating the service instance URL, append the path /actuator/refreshmirrors to that URL. Then make an authenticated HTTP POST request. If you have logged in using the cf CLI, you can use the cf oauth-token command to provide the OAuth 2.0 token for use in your request:

$ curl -X POST -H "Authorization: $(cf oauth-token)" -H "Content-Type: application/json" https://config-server-a5782192-8036-4f57-8312-4756a2604240.apps.example.com/actuator/refreshmirrors

Refreshing a client app

In a Spring client app, you can use RefreshScope to allow for refreshing of Spring beans which use configuration served by the Config Server. For more information, see the Refresh Client Application Configuration section of Writing Client Applications.

check-circle-line exclamation-circle-line close-line
Scroll to top icon