App runtime

Reference guide for the application runtime container environment.

The app runtime is the environment apps are executed in.

Buildpack AppsContainer Image Apps
System librariesProvided by the StackProvided in the container
Network accessFull access through Envoy sidecarFull access through Envoy sidecar
File systemEphemeral storageEphemeral storage
Language runtimeSupplied by the Stack or BuildpackBuilt into the container
UserSpecified by the StackSpecified on the container
Isolation mechanismKubernetes PodKubernetes Pod
DNSProvided by KubernetesProvided by Kubernetes

Environment variables

Environment variables are injected into the app at runtime by Kubernetes. Variables are added based on the following order, where later values override earlier ones with the same name:

  1. Space (set by administrators)
  2. App (set by developers)
  3. System (set by Kf)

Kf provides the following system environment variables:

VariablePurpose
CF_INSTANCE_ADDRThe cluster-visible IP:PORT of the App instance.
CF_INSTANCE_GUIDThe UUID of the App instance.
INSTANCE_GUIDAlias of CF_INSTANCE_GUID.
CF_INSTANCE_INDEXThe index number of the App instance, this will ALWAYS be 0.
INSTANCE_INDEXAlias of CF_INSTANCE_INDEX.
CF_INSTANCE_IPThe cluster-visible IP of the App instance.
CF_INSTANCE_INTERNAL_IPAlias of CF_INSTANCE_IP
VCAP_APP_HOSTAlias of CF_INSTANCE_IP
CF_INSTANCE_PORTThe cluster-visible port of the App instance. In Kf this is the same as PORT.
DATABASE_URLThe first URI found in a VCAP_SERVICES credential.
LANGRequired by Buildpacks to ensure consistent script load order.
MEMORY_LIMITThe maximum amount of memory in MB the App can consume.
PORTThe port the App should listen on for requests.
VCAP_APP_PORTAlias of PORT.
VCAP_APPLICATIONA JSON structure containing App metadata.
VCAP_SERVICESA JSON structure specifying bound services.

Service credentials from bound services get injected into Apps via the VCAP_SERVICES environment variable. The variable is a valid JSON object with the following structure.

VCAPServices

A JSON object where the keys are Service labels and the values are an array of VCAPService. The array represents every bound service with that label. User provided services are placed under the label user-provided.

Example

{
  "mysql": [...],
  "postgresql": [...],
  "user-provided": [...]
}

VCAPService

This type represents a single bound service instance.

Example

{
  "binding_name": string,
  "instance_name": string,
  "name": string,
  "label": string,
  "tags": string[],
  "plan": string,
  "credentials": object
}

Fields

FieldTypeDescription
binding_namestringThe name assigned to the service binding by the user.
instance_namestringThe name assigned to the service instance by the user.
namestringThe binding_name if it exists; otherwise the instance_name.
labelstringThe name of the service offering.
tagsstring[]An array of strings an app can use to identify a service instance.
planstring[]The service plan selected when the service instance was created.
credentialsobjectThe service-specific credentials needed to access the service instance.

VCAP_APPLICATION

TheVCAP_APPLICATION environment variable is a JSON object containing metadata about the App.

Example

{
  "application_id": "12345",
  "application_name": "my-app",
  "application_uris": ["my-app.example.com"],
  "limits": {
    "disk": 1024,
    "mem": 256
  },
  "name": "my-app",
  "process_id": "12345",
  "process_type": "web",
  "space_name": "my-ns",
  "uris": ["my-app.example.com"]
}

Fields

FieldTypeDescription
application_idstringThe GUID identifying the App.
application_namestringThe name assigned to the App when it was pushed.
application_urisstring[]The URIs assigned to the App.
limitsobjectThe limits to disk space, and memory permitted to the App. Memory and disk space limits are supplied when the App is deployed, either on the command line or in the App manifest. Disk and memory limits are represented as integers, with an assumed unit of MB.
namestringIdentical to application_name.
process_idstringThe UID identifying the process. Only present in running App containers.
process_typestringThe type of process. Only present in running App containers.
space_namestringThe human-readable name of the Space where the App is deployed.
urisstring[]Identical to application_uris.

Missing Fields

Some fields in VCAP_APPLICATION that are in Cloud Foundry are currently not supported in Kf.

Besides CF-specific and deprecated fields (cf_api, host, users) the fields that are not supported in Kf are:

  • application_version (identical to version)
  • organization_id
  • organization_name
  • space_id
  • start (identical to started_at)
  • started_at_timestamp (identical to state_timestamp)