Skip to content

Commit 163ae24

Browse files
committed
Add Support for File based Service Binding Information
This RFC suggests to introduce an alternative option for the CF platform to provide Service Binding information to applications.
1 parent 77e174a commit 163ae24

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Meta
2+
[meta]: #meta
3+
- Name: Add Support for File based Service Binding Information
4+
- Start Date: 2024-03-11
5+
- Author(s): @beyhan
6+
- Status: Draft
7+
- RFC Pull Request: (fill in with PR link after you submit it)
8+
9+
10+
11+
## Summary
12+
13+
The current contract between the CF platform and applications for service binding information is based on an environment variable. The Linux Kernel defines size limit per environment variable and there are also other limitations with this approach. That is why, CF should add support for an alternative option to provide service binding information which can address the limitations of the current approach.
14+
15+
## Problem
16+
17+
The CF platform provides Service Binding Information to hosted applications via the [VCAP_SERVICES environment variable](https://docs.cloudfoundry.org/devguide/services/application-binding.html). There are following challenges with this approach:
18+
- The environment variable length has a hard limit of `131072` bytes per variable which is controlled by the underlying [Linux kernel](https://github.com/torvalds/linux/blob/master/include/uapi/linux/binfmts.h). The environment variable size is defined by `MAX_ARG_STRLEN`, which is a constant with the value `PAGE_SIZE*32` where page size is `4096` bytes. This means that to change the size limit for the CF platform a recompiled kernel with updated value for `MAX_ARG_STRLEN` is required. This limit could be an issue for applications using many services. If the limit is reached by an application, it will fail to stage.
19+
- Updates of the Service Binding Information require restage. This is not optimal for an eventual support of [Binding rotation](https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md#binding-rotation) specification from the OSBI API spec.
20+
21+
22+
## Proposal
23+
24+
The CFF community should implement an alternative approach for service binding information based on `tmpfs` file(s). Using a file or files to provide service binding information to applications will address the challenges listed in the problem section because:
25+
- The file size limit can be controlled by the CF platform
26+
- Already today CF uses `tmpfs` for [Instance Identity Credentials](https://docs.cloudfoundry.org/devguide/deploy-apps/instance-identity.html) which are rotated without restarting the application every `24h` by default
27+
28+
The two approaches should be supported in parallel. Users should be able to select which approach Cloud Controller should use to deliver the binding information.
29+
There are two alternatives regarding service binding file organization:
30+
1. The VCAP_SERVICES content is stored in a file which location is specified via the VCAP_SERVICES_FILE_PATH env var in the same format as the VCAP_SERVICES environment variable
31+
* Advantages:
32+
* Less disruptive for applications consuming the `VCAP_SERVICES` env var
33+
* Less implementation effort for the Cloud Controller
34+
* Disadvantages:
35+
* Can’t make use of tools and libraries from the Cloud Native community because K8s specifies a different file structure and format for the service binding information
36+
2. Implement the K8s service binding specification. The environment variable `SERVICE_BINDING_ROOT` defines the location for the service bindings. There is a file per service binding. The name of the file and the format follow the [K8s specification](https://servicebinding.io/):
37+
* Advantages:
38+
* CF community could re-use service binding libraries from the Cloud Native community
39+
* Moving application between CF or K8s deployments will be easier
40+
* Disadvantages
41+
* Higher implementation efforts for the Cloud Controller
42+
* Applications with binding information >`130KB` have to go with the file option and adopt it
43+
44+
45+
The 2) alternatives offers more than just addressing the issue of this RFC. It suggests an option to evolve the CF platform towards a different service binding specification defined by the Cloud Native community. This means higher implementation efforts for the CF platform and application developers, but possible benefits from the Cloud Native community. This RFC has a light preference for the 2) alternative because of the listed advantages but the feedback of the CF community is wanted here.
46+
47+
Additionally, the application environment is stored in the `CCDB` and `BBS DB` that is why we should define a limit for the size of it, which makes it possible to be stored in the according DBs and doesn’t impact the performance of the communication between Cloud Controller and the Diego API. That is why this RFC suggests a limit of `1MB`, which is roughly ten times higher than the current one of 130KB. This is subject for evaluation during the implation of this RFC.
48+
49+
### Implementation Overview
50+
51+
Cloud Controller should introduce a new app feature for activating the file-based approach. This means that the [App Features API](https://v3-apidocs.cloudfoundry.org/version/3.159.0/index.html#app-features) could be used here and a new feature flag called “file-based-service-bindings" should be introduced.
52+
The [contract](https://github.com/cloudfoundry/bbs/blob/main/doc/actions.md) between Cloud Controller and Diego should be extended so that file name and file content for the application container can be specified. E.g. the run action could look like this when file approach is selected:
53+
54+
```
55+
action := &models.RunAction{
56+
Path: "/path/to/executable",
57+
Args: []string{"some", "args to", "pass in"},
58+
Dir: "/path/to/working/directory",
59+
User: "username",
60+
EnvironmentVariables: []*models.EnvironmentVariable{
61+
{
62+
Name: "ENVNAME",
63+
Value: "ENVVALUE",
64+
},
65+
},
66+
Files: []*models.Files{
67+
{
68+
Name: "/etc/cf-instance-binding",
69+
Value: "VALUE",
70+
},
71+
},
72+
ResourceLimits: &models.ResourceLimits{
73+
Nofile: 1000,
74+
},
75+
LogSource: "some-log-source",
76+
SuppressLogOutput: false,
77+
}
78+
```
79+
80+
## Workstreams
81+
82+
### App Runtime Interfaces WG
83+
84+
Cloud Controller should be extended with an App Feature to activate the new file base Service Binding option. If the file-based service binding feature is active the Cloud Controller should generate a Run action, which configures the `VCAP_SERVICES` content to be stored as tmpfs file in the application container instead of environment variable.
85+
86+
Additionally, the suggest limit for the size should be implemented.
87+
88+
### App Runtime Platform WG
89+
90+
Diego should add support for the new argument of the Run action to create files with the desired content. Like the [Instance Identity credentials](https://docs.cloudfoundry.org/devguide/deploy-apps/instance-identity.html) implementation, the [Diego Executor](https://github.com/cloudfoundry/executor) should be extended to prepare the `tmpfs` mount and create the required files for an application container. For reference there is a [CredManager](https://github.com/cloudfoundry/executor/blob/db9758c0142ae9c11dad26de672735fb20566105/depot/containerstore/credmanager.go) , InstanceIdentityHandler and the `tmpfs` mount is configured in the [Diego release](https://github.com/cloudfoundry/diego-release/blob/2d7d7c1373f2a61077c74e33a397a5f69b11b131/jobs/rep/templates/setup_mounted_data_dirs.erb#L38-L56) for the current implementation of the Instance Identity Credentials.
91+
92+
## Possible Future Work
93+
94+
The App Features API aren’t supported currently in the CF CLI and [app manifest](https://docs.cloudfoundry.org/devguide/deploy-apps/manifest-attributes.html). To make the use of this proposal for CF operators easier this should be addressed.
95+
96+
### App Manifest Attributes Proposal
97+
98+
```
99+
---
100+
applications:
101+
- name: test-app
102+
features:
103+
- file-based-service-bindings
104+
```
105+
106+
### CF CLI new Commands Proposal
107+
108+
- `app-feature-flags` Retrieve list of available app feature flags with status
109+
- `app-feature-flag` Retrieve an individual app feature flag with status
110+
- `enable-app-feature-flag` Allow use of an app feature
111+
- `disable-app-feature-flag` Disable use of an app feature
112+

0 commit comments

Comments
 (0)