-
Notifications
You must be signed in to change notification settings - Fork 363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Technical Specification: Translation of VCAP_SERVICES to Service Binding Files #4036
Comments
@philippthun , we could have this case, where both properties are stored in the same way as files
Then w/o further metadata it is not possible to recover how the VCAP_SERVICES was intended to look like |
If we have to do any drastic encoding based on the findings #4036 (comment) as part of this translation it would be good to know that existing libraries (like https://github.com/spring-cloud/spring-cloud-bindings) that automatically parse file based service bindings will function. |
SerializationIn our exploration of this topic, we've identified an open question: How should we write the binding content into files? Given the service binding content (samples are based on experiments available in this repository):
We've outlined two options below:
Based on the servicebindings.io specification and available libraries, the implicit assumption is that binding secret entries should contain plain strings. Libraries like spring-cloud-bindings read files as-is and trim them, making Option 1 more compatible to prevent issues with unintended quotes as shown here based on the samples above. Backwards CompatibilityChoosing Option 1 (JSON Decoded) affects the translation from
|
Another solution that avoids the drawbacks of the options 1 and 2 mentioned above is to go back to the original RFC0030 Add Support for File based Service Binding Information. We discussed here 2 alternatives:
We could actually implement both alternatives and give the CF user the choice by app feature flags (mutual exclusive), e.g.
(better naming proposals for the feature flags are welcome) Given the following
With enabled feature flag
With enabled feature flag
Comparison of option 3 with the options 1 (Generate a
|
From the name options above I would vote for:
|
In regards to serialization, I don't see any of these approaches as being a problem, but 3.) would be my preference (@stephanme solution). I think you give the app developer the choice on the format they want and it helps minimize change for them. If the app dev is using java-cfenv then they keep using vcap_services just from a file, which the library can handle. If they want to use spring cloud binding then it should be presented in service binding files. Giving the choice means apps keep working and there's no messy migration. Probably the only draw back I see there is for Buildpack authors. If you have Buildpacks that look at service bindings, like a number of Paketo Buildpacks, then they need to know if they should look at vcap_services or service bindings. Fortunately in libcnb we have a layer that handles this. It is capable of presenting vcap_services data to buildpacks through the same interface they fetch service binding data. Presently it pulls from the env variable but we can easily look at a file instead. |
We discussed the proposals in the ARI WG meeting on 28.1. (unfortunately with low attendance). If there are no strong arguments until end of this week we will go for option 3 (user can chose between a servicebinding.io and a vcap-services variant, both file based). |
I would vote for option 3 |
Decision: we continue with option 3. |
The RFC update is available in cloudfoundry/community#1069. Please put thumps up on it if it fine for you. FYI @Samze, @dmikusa |
This document describes how service binding details, exposed to application processes in the
VCAP_SERVICES
environment variable, are translated into a list (tree) of files known as Service Binding Files.Translation Process
The translation process begins with the system checking if the application process is enabled for file-based service bindings. If enabled, it builds a set of valid service binding files.
Each service binding's name is validated for uniqueness and compatibility. Duplicate or invalid binding names result in an
IncompatibleBindings
error. Binding names must match[a-z0-9\-.]{1,253}
as specified in the Service Binding Specification for Kubernetes [1].Multiple service binding files are generated for each service binding. The service binding's name acts as the directory name, while various properties of the service binding (such as credentials and attributes) act as file names.
The
credentials
attribute inVCAP_SERVICES
is a JSON object. Each top-level key within this object will be matched to a file within the service binding's directory, and the corresponding value will be the file content. In casecredentials
contain a deeply nested structure, still only the top-level keys will be represented as files. Nested structures inside their value will be serialized as JSON objects. The same applies if the value is a list. (See example no. 1)Existing credential keys can be overwritten by other attributes, that are
VCAP_SERVICES
attributes as defined in the Cloud Foundry Documentation [2] plustype
andprovider
. The full list of reserved file names is:binding-guid
,binding-name
,instance-guid
,instance-name
,name
,label
,tags
,plan
,syslog-drain-url
,volume-mounts
,type
, andprovider
. Overwriting an existing key does not result in an error. (See example no. 2)All file names must match the same schema as the service binding's name. An invalid name results in an
IncompatibleBindings
error. TheVCAP_SERVICES
attributes are transformed to comply to this schema, i.e. underscores are replaced by hyphens, so that e.g.VCAP_SERVICES
attributebinding_guid
becomes file namebinding-guid
. (See example no. 3)If a service binding value represents a list (like it is the case for tags and volume mounts), the file content will be a JSON representation of the array.
Empty lists or
null
values are omitted, i.e. no file will be created. (See example no. 3)The total bytesize of the generated files is validated. If the total bytesize (of file paths and contents) exceeds the maximum allowed bytesize limit (default is 1,000,000 bytes), an
IncompatibleBindings
error is raised.Examples
[1] https://servicebinding.io/spec/core/1.1.0/#workload-projection
[2] https://docs.cloudfoundry.org/devguide/deploy-apps/environment-variable.html#VCAP-SERVICES
The text was updated successfully, but these errors were encountered: