spring-projects / spring-projects/spring-boot
Support loading file-based service bindings
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 81.5k
- Forks
- 42.7k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 65
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 https://github.com/spring-projects/spring-boot/blob/f3958ae9e721b7068ba018db7a86709bde8ce0ba/core/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java#L156-L167 needs to be adapted to consider 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read CloudFoundryVcapEnvironmentPostProcessor.java, especially the method around lines 156-167, and review RFC-0030's file-based binding option. Support VCAP_SERVICES_FILE_PATH when VCAP_SERVICES is absent, while preserving the existing VCAP_SERVICES behavior; the completed change should load the file's VCAP_SERVICES-format content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot
- Domain
- cloud
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100