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:

  1. Store the VCAP_SERVICES content in a file. The file's location is specified by the VCAP_SERVICES_FILE_PATH environment variable, and the content format remains the same as the VCAP_SERVICES environment variable.
  2. The second option is an implementation of the K8s service binding specification. The environment variable SERVICE_BINDING_ROOT defines 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.

Comment From: ThomasVitale

Option 2 might be related to https://github.com/spring-projects/spring-boot/issues/43882 and https://github.com/spring-projects/spring-boot/issues/21322

Comment From: Satvikhood

I am interested in this issue, but have no idea how to solve, can anyone help me to understand this, i am ready to work on this

Comment From: wilkinsona

Thanks for your interest, @Satvikhood. Unfortunately, we don't have the bandwidth to provide that level of guidance for this issue. If you're looking for an issue where we can provide guidance or that's more straightforward, please keep an eye out for issues labelled with https://github.com/spring-projects/spring-boot/labels/status%3A%20ideal-for-contribution.

Comment From: hojooo

Hello! I'm interested in working on this issue. I'd like to start with file-based VCAP_SERVICES as suggested in the issue description. Would it be okay if I submit a PR for this?