-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Description
This issue proposes to add support for file-based service bindings in Spring Boot, as specified in Cloud Foundry RFC-0030 and supported since CF version v48.5.0.
Currently, service binding information is provided to applications through the VCAP_SERVICES environment variable, which has:
- Size Limit: The Linux kernel imposes a size limit of 130KB on environment variables, which can be reached when an application is bound to a large number of services.
- Dynamic Updates: Service binding updates require an application to be restaged, which prevents the adoption of features like on-the-fly credential rotation.
That is why, the RFC-0030 introduces a file-based approach to address these limitations. There are two alternatives support in CF to provide the file-based service bindings:
- Store the
VCAP_SERVICEScontent in a file. The file's location is specified by theVCAP_SERVICES_FILE_PATHenvironment variable, and the content format remains the same as theVCAP_SERVICESenvironment variable. - The second option is an implementation of the K8s service binding specification. The environment variable
SERVICE_BINDING_ROOTdefines the location for the service bindings. The name of the file and the format follow the K8s specification
I think as first step support for option 1) can be added and if there is need for the 2) option could be done in a separate issue. To support the 1) option, the CloudFoundryVcapEnvironmentPostProcessor should be enhanced to detect the presence of the VCAP_SERVICES_FILE_PATH environment variable if VCAP_SERVICES isn't set. The CF platform sets either VCAP_SERVICES or VCAP_SERVICES_FILE_PATH but not both environment variables in the same time. I don't have experience with the spring-boot code base but it looks to me like the method
Lines 156 to 167 in f3958ae
| private Properties getPropertiesFromServices(Environment environment, JsonParser parser) { | |
| Properties properties = new Properties(); | |
| try { | |
| String property = environment.getProperty("VCAP_SERVICES", "{}"); | |
| Map<String, Object> map = parser.parseMap(property); | |
| extractPropertiesFromServices(properties, map); | |
| } | |
| catch (Exception ex) { | |
| this.logger.error("Could not parse VCAP_SERVICES", ex); | |
| } | |
| return properties; | |
| } |
VCAP_SERVICES_FILE_PATH env var when VCAP_SERVICES is not present.
It would be from benefit to support this new file-based service bindings approach because in CF ecosystem we see more and more users starting to use this feature because of the mentioned size limit for environment variables.