You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: deploy-apps/environment-variable.html.md.erb
+23-3Lines changed: 23 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Environment variables are the means <%= vars.app_runtime_abbr %> uses to communi
15
15
For information about setting your own app-specific environment variables, see the [Environment variable](./manifest.html#env-block) in _Deploying with app manifests_.
16
16
17
17
<pclass="note important">
18
-
Do not use user-provided environment variables for security-sensitive information such as credentials. They might unintentionally show up in cf CLI output and Cloud Controller logs. Use <ahref="../services/user-provided.html">user-provided service instances</a> instead. The system-provided environment variable <ahref="#VCAP_SERVICES">VCAP_SERVICES</a> is properly redacted for user roles such as Space Supporter and in Cloud Controller log files.</p>
18
+
Do not use user-provided environment variables for security-sensitive information such as credentials. They might unintentionally show up in cf CLI output and Cloud Controller logs. Use <ahref="../services/user-provided.html">user-provided service instances</a> instead. Credentials which are provided to the app via service bindings are redacted for user roles such as Space Supporter and in Cloud Controller log files.</p>
19
19
20
20
<pclass="note important">
21
21
The maximum size of an environment variable is 130 KB. This limit applies also to <%=vars.app_runtime_abbr%> system environment variables such as <code>VCAP_SERVICES</code> and <code>VCAP_APPLICATION</code>.</p>
@@ -25,10 +25,15 @@ The maximum size of an environment variable is 130 KB. This limit applies a
25
25
26
26
Using the Cloud Foundry Command Line Interface (cf CLI), you can run the `cf env` command to view the <%=vars.app_runtime_abbr%> environment variables for your app. The `cf env` command displays the following environment variables:
27
27
28
-
* The `VCAP_APPLICATION` and `VCAP_SERVICES` variables provided in the container environment
29
-
28
+
* The `VCAP_APPLICATION` variable, which contains app metadata
30
29
* The user-provided variables set using the `cf set-env` command
31
30
31
+
There are 3 possible ways of providing service binding data to apps, see [Credential Delivery Methods](../services/application-binding.html#credential-delivery-methods). Depending on the chosen method there will be one of the following environment variables:
For more information about the `cf env` command, see [env](http://cli.cloudfoundry.org/en-US/cf/env.html) in the cf CLI documentation. For more information about the `cf set-env` command, see [set-env](http://cli.cloudfoundry.org/en-US/cf/set-env.html) in the cf CLI documentation.
33
38
34
39
The following example demonstrates the environment variables `cf env` displays:
@@ -100,12 +105,14 @@ The following table lists the system variables available to your application con
100
105
| `PATH` | x | x | x |
101
106
| `PORT` | x | | |
102
107
| `PWD` | x | x | x |
108
+
| `SERVICE_BINDING_ROOT` | x | x | x |
103
109
| `TMPDIR` | x | | x |
104
110
| `USER` | x | x | x |
105
111
| `VCAP_APP_HOST` | x | | |
106
112
| `VCAP_APP_PORT` | x | | |
107
113
| `VCAP_APPLICATION` | x | x | x |
108
114
| `VCAP_SERVICES` | x | x | x |
115
+
| `VCAP_SERVICES_FILE_PATH` | x | x | x |
109
116
110
117
### <aid='CF-INSTANCE-ADDR'></a> CF_INSTANCE_ADDR
111
118
@@ -222,6 +229,12 @@ The present working directory where the buildpack that processed the app ran.
The root directory location, which contains the service binding information. This needs to be enabled by an app feature flag. See [Service Binding K8s](../services/application-binding.html#service-binding-k8s) for information on how to enable and how service binding data is stored in this directory.
235
+
236
+
For example: `SERVICE_BINDING_ROOT=/etc/cf-service-bindings`
237
+
225
238
### <aid='TMPDIR'></a> TMPDIR
226
239
227
240
The directory location where temporary and staging files are stored.
@@ -270,6 +283,8 @@ This environment variable contains the associated attributes for a deployed app.
270
283
271
284
For bindable services, <%=vars.app_runtime_abbr%> adds connection details to the `VCAP_SERVICES` environment variable when you restart your app, after binding a service instance to your app. For more information about bindable services, see [Services overview](../services/index.html).
272
285
286
+
This is the default [Credential Delivery Method](../services/application-binding.html#credential-delivery-methods).
287
+
273
288
<%=vars.app_runtime_abbr%> returns the results as a JSON document that contains an object for each service for which one or more instances are bound to the app. The service object contains a child object for each instance of the service that is bound to the app.
274
289
275
290
The following table defines the attributes that describe a bound service. The key for each service in the JSON document is the same as the value of the "label" attribute.
The path to the file containing the service binding information in JSON format. This needs to be enabled by an app feature flag. See [File-based VCAP services](../services/application-binding.html#file-based-vcap-services) for more information.
362
+
363
+
For example: `VCAP_SERVICES_FILE_PATH=/etc/cf-service-bindings/vcap_services`
344
364
345
365
## <aid='evgroups'></a> Environment variable groups
Copy file name to clipboardExpand all lines: deploy-apps/large-app-deploy.html.md.erb
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,8 @@ To deploy large apps to <%= vars.app_runtime_abbr %>, ensure that:
26
26
27
27
* The size of each environment variable for your app does not exceed 130 KB. This includes <%=vars.app_runtime_abbr%> system environment variables such as `VCAP_SERVICES` and `VCAP_APPLICATION`. For more information, see [<%=vars.app_runtime_abbr%> environment variables](environment-variable.html).
28
28
29
+
* If VCAP_SERVICES does get too large either because of too many service bindings or too much data provided by the services, check out the other two [Credential Delivery Methods](../services/application-binding.html#credential-delivery-methods) which have a limit of 1 MB.
30
+
29
31
* You push only the files that are necessary for your app. To meet this requirement, push only the directory for your app, and remove unneeded files or use the `.cfignore` file to specify excluded files. For more information about specifying excluded files, see [Ignore unnecessary files when pushing](prepare-to-deploy.html#exclude) in _Considerations for Designing and Running an App in the Cloud_.
30
32
31
33
* You configure Cloud Foundry Command Line Interface (cf CLI) staging, startup, and timeout settings to override settings in the manifest, as necessary:
Copy file name to clipboardExpand all lines: deploy-apps/manifest-attributes.html.md.erb
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -695,7 +695,7 @@ For example:
695
695
<divclass="note important">
696
696
<ul>
697
697
<li>You must name variables with alphanumeric characters and underscores. Non-conforming variable names might cause unpredictable behavior.</li>
698
-
<li>Do not use user-provided environment variables for security sensitive information such as credentials, because they might unintentionally show up in cf CLI output and Cloud Controller logs. Use <ahref="../services/user-provided.html">user-provided service instances</a> instead. The system-provided environment variable <ahref="./environment-variable.html#VCAP-SERVICES">VCAP_SERVICES</a> is properly redacted for user roles such as Space Supporter and in Cloud Controller log files.</li>
698
+
<li>Do not use user-provided environment variables for security sensitive information such as credentials, because they might unintentionally show up in cf CLI output and Cloud Controller logs. Use <ahref="../services/user-provided.html">user-provided service instances</a> instead. Credentials which are provided to the app via service bindings are redacted for user roles such as Space Supporter and in Cloud Controller log files.</li>
699
699
</ul>
700
700
</div>
701
701
@@ -776,8 +776,7 @@ For example:
776
776
- instance_XYZ
777
777
```
778
778
779
-
You can bind an app to a service instance by setting the `VCAP_SERVICES` environment variable. For more information, see [Bind a
780
-
service](../services/application-binding.html#bind) in _Delivering Service Credentials to an App_.
779
+
For more information, see [Bind a service](../services/application-binding.html#bind) in _Delivering Service Credentials to an App_.
781
780
782
781
783
782
## <aid='deprecated'></a> Deprecated app manifest features
Copy file name to clipboardExpand all lines: services/_using-vol-services.html.md.erb
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -133,6 +133,8 @@ To access the volume service from your app, you must know which file path to use
133
133
134
134
You can view the file path in the details of the service binding, which are available from the `VCAP_SERVICES` environment variable. See [VCAP_SERVICES](../deploy-apps/environment-variable.html#view-env).
135
135
136
+
Check [Credential Delivery Methods](./application-binding.html#credential-delivery-methods) on how to retrieve the volume mount information if you chose to use file-based service bindings.
@@ -9,7 +9,9 @@ You can bind your apps to service instances for the purpose of generating creden
9
9
10
10
## <aid='bind'></a>Bind a service instance
11
11
12
-
Binding a service instance to your app triggers credentials to be provisioned for the service instance and delivered to the app runtime in the [VCAP_SERVICES](../deploy-apps/environment-variable.html) environment variable. For details about consuming these credentials with your app, see [Using bound service instances](#use).
12
+
Binding a service instance to your app triggers credentials to be provisioned for the service instance and delivered to the app runtime. CloudFoundry offers 3 different methods to deliver those credentials to the app.
13
+
14
+
For details about the different delivery methods and consumption of these credentials with your app, see [Credential Delivery Methods](#credential-delivery-methods).
13
15
14
16
Not all services support binding, as some services deliver value to users directly without integration with an app. In many cases, binding credentials are unique to an app, and another app bound to the same service instance receives different credentials, but this depends on the service.
15
17
@@ -25,6 +27,140 @@ $ cf restart my-app
25
27
<pclass="note important">
26
28
You must restart or in some cases re-push your app for changes to be applied to the <ahref="../deploy-apps/environment-variable.html">VCAP_SERVICES</a> environment variable and for the app to recognize these changes.</p>
After your service instance is created and bound to your app, the credentials together with some metadata are available in the app container and can be consumed by your app.
33
+
There are the following three delivery methods, which are mutually exclusive. The developer can choose which one to use and needs to adjust the consumption in the app accordingly.
34
+
For details about consuming credentials specific to your development framework, see the Service Binding section in the documentation for your framework's [buildpack](../../buildpacks/index.html).
By default credentials and additional metadata for all bound service instances are stored in the <ahref="../deploy-apps/environment-variable.html">VCAP_SERVICES</a> environment variable.
39
+
40
+
There are two methods developers can use to have their apps consume binding credentials.
41
+
42
+
* **Parse the JSON yourself:** See the documentation for [VCAP_SERVICES](../deploy-apps/environment-variable.html#VCAP-SERVICES). Helper libraries are available for some frameworks.
43
+
* **Auto-configuration:** Some buildpacks create a service connection for you by creating additional environment variables, updating config files, or passing system parameters to the JVM.
44
+
45
+
For checking the binding data manually app developers can use `cf env`. See [View Env](../deploy-apps/environment-variable.html#view-env).
46
+
47
+
<pclass="note important">
48
+
The maximum size of content of the VCAP_SERVICES environment variable is 130 KB. If you want to bind more services to the app or the services you want to bind provide lots of data, you can use one of the other methods.</p>
This delivery method is used when the app feature [file-based-vcap-services](https://v3-apidocs.cloudfoundry.org/index.html#app-features) is enabled.
53
+
The environment variable [VCAP_SERVICES_FILE_PATH](../deploy-apps/environment-variable.html#VCAP-SERVICES-FILE-PATH) will be made available in the app container and contains the path to a file containing the same content as the VCAP_SERVICES environment variable above.
The vcap_services file content cannot exceed 1 MB, otherwise an <code>IncompatibleBindings</code> error is raised.</p>
63
+
64
+
#### <aid='service-binding-k8s'></a> Service Binding K8s (experimental)
65
+
66
+
This delivery method is used when the app feature [service-binding-k8s](https://v3-apidocs.cloudfoundry.org/index.html#app-features) is enabled.
67
+
The environment variable [SERVICE_BINDING_ROOT](../deploy-apps/environment-variable.html#SERVICE-BINDING-ROOT) will be made available in the app container and contains the path to the root folder of a file structure containing binding information.
68
+
This method is fully compatible with the specification on [servicebinding.io](https://servicebinding.io/), which is used by Kubernetes as well.
The bytesize of all files and their content combined cannot exceed 1 MB, otherwise an <code>IncompatibleBindings</code> error is raised.</p>
78
+
79
+
Here are some examples outlining the transformation of VCAP_SERVICES to the file structure:
80
+
81
+
Nested structures inside their value will be serialized as JSON objects. The same applies if the value is a list.
82
+
83
+
```
84
+
VCAP_SERVICES= {
85
+
"foo": [
86
+
{
87
+
"name": "foo",
88
+
"credentials": {
89
+
"simple": "value",
90
+
"deeply": {
91
+
"nested": "value"
92
+
},
93
+
"list": ["v", "a", "l", "u", "e"]
94
+
}
95
+
}
96
+
]
97
+
}
98
+
99
+
Service Binding Files:
100
+
foo/name: foo
101
+
foo/simple: value
102
+
foo/deeply: {"nested":"value"}
103
+
foo/list: ["v","a","l","u","e"]
104
+
```
105
+
106
+
Existing credential keys can be overwritten by other attributes, that are [VCAP_SERVICES](../deploy-apps/environment-variable.html#VCAP-SERVICES) attributes plus type and provider. 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, and provider. Overwriting an existing key does not result in an error.
107
+
108
+
```
109
+
VCAP_SERVICES= {
110
+
"foo": [
111
+
{
112
+
"name": "foo",
113
+
"credentials": {
114
+
"name": "user",
115
+
"secret": "password"
116
+
}
117
+
}
118
+
]
119
+
}
120
+
121
+
Service Binding Files:
122
+
foo/name: foo
123
+
foo/secret: password
124
+
```
125
+
126
+
Empty lists or null values are omitted, i.e. no file will be created.
Binding names and keys resulting in filenames must match [a-z0-9\-.]{1,253}. Invalid binding names and keys will result in IncompatibleBindings error. VCAP_SERVICES attributes are transformed to comply to this schema, i.e. underscores are replaced by hyphens, so that e.g. VCAP_SERVICES attribute binding_guid becomes file name binding-guid.
Some services support additional configuration parameters with the bind request. These parameters are passed in a valid JSON object containing service-specific configuration parameters, provided either in-line or in a file. For a list of supported configuration parameters, see documentation for the particular service offering.
@@ -90,7 +226,7 @@ OK
90
226
91
227
The provided name is available in the `name` and `binding_name` properties in the [VCAP_SERVICES](../deploy-apps/environment-variable.html) environment variable:
92
228
93
-
~~~
229
+
```
94
230
"VCAP_SERVICES": {
95
231
"service-name": [
96
232
{
@@ -100,16 +236,7 @@ The provided name is available in the `name` and `binding_name` properties in th
100
236
}
101
237
]
102
238
}
103
-
~~~
104
-
105
-
### <aid='use'></a>Using bound service instances
106
-
107
-
After your service instance is created and bound to your app, you must configure the app to dynamically fetch the credentials for your service instance. The [VCAP_SERVICES](../deploy-apps/environment-variable.html#VCAP-SERVICES) environment variable contains credentials and additional metadata for all bound service instances. There are two methods developers can use to have their apps consume binding credentials.
108
-
109
-
* **Parse the JSON yourself:** See the documentation for [VCAP_SERVICES](../deploy-apps/environment-variable.html#VCAP-SERVICES). Helper libraries are available for some frameworks.
110
-
* **Auto-configuration:** Some buildpacks create a service connection for you by creating additional environment variables, updating config files, or passing system parameters to the JVM.
111
-
112
-
For details about consuming credentials specific to your development framework, see the Service Binding section in the documentation for your framework's [buildpack](../../buildpacks/index.html).
239
+
```
113
240
114
241
## <aid='update-credentials'></a>Update service credentials
0 commit comments