Red Hat Bugzilla – Bug 971208
[RFE] Generic environment variables for IP and PORT are deprecated - now cartridge-specific
Last modified: 2015-07-28 21:16:00 EDT
"These variables provide environment information for your application. Your application can read these environment variables and use the information to configure itself for the OpenShift environment."
Table 7.2. Informational Environment Variables
Environment Variable Name Example Purpose
OPENSHIFT_APP_DNS appname-namespace.example.com The application's fully-qualified domain name
OPENSHIFT_APP_NAME appname The application's name
OPENSHIFT_APP_UUID 0123456789abcdef0123456789abcdef The UUID of the application (32 hex characters)
OPENSHIFT_INTERNAL_IP 127.0.250.1 The IP address the application listens on
OPENSHIFT_INTERNAL_PORT 8080 The port the application receives requests from
In my node.js app the OPENSHIFT_INTERNAL_IP and OPENSHIFT_INTERNAL_PORT are not available in the environment.
Instead, I need to use the following environment variables:
OPENSHIFT_NODEJS_IP Purpose: The IP address for a node application
OPENSHIFT_NODEJS_PORT Purpose: The IP port for a node application
example usage is like this:
// Default to 127.0.0.1 and 8080 for local testing, when the app is not running on OpenShift
myApp.IPAddress = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
myApp.IPPort = process.env.OPENSHIFT_NODEJS_PORT || 8080;
In this case it's obvious when the NODEJS_IP and _PORT variables are available - when you are using a node.js gear. However, when are the OPENSHIFT_INTERNAL_IP and _PORT variables available? That should probably be made explicit, so that peeps know when to, and when not to rely on their existence.
mmcgrath: (OPENSHIFT_INTERNAL_IP) is deprecated as of this erelease but still there for older apps for the time being
The NODEJS variables are documented here: https://github.com/openshift/origin-server/tree/master/cartridges/openshift-origin-cartridge-nodejs
Not all the cartridges contain the environment variables, but this one does, for example:
Here's the list of cartridges: https://github.com/openshift/origin-server/tree/master/cartridges
Here's the cartridge definition guidelines that talk about defining those cartridge-specific variables:
Yep, that's it. The _PORT and _IP variable is defined per-cartridge in the manifest.yml file in the metadata subdirectory of the cartridge. Here's an example: The Ruby cartridge readme (https://github.com/openshift/origin-server/blob/master/cartridges/openshift-origin-cartridge-ruby/README.md) does not detail the Ruby cartridge variables, but you can see them here: https://github.com/openshift/origin-server/blob/master/cartridges/openshift-origin-cartridge-ruby/metadata/manifest.yml#L29
I'd like to request a new section with a series of tables for each cartridge detailing the specific environment variables defined in each one.
Version 1 cartridges provided the environment variables OPENSHIFT_INTERNAL_IP and OPENSHIFT_INTERNAL_PORT. Version 1 cartridges are deprecated, and new gears use Version 2 cartridges.
Version 2 cartridges use cartridge-specific environment variables to provide address and port information for your application. Gears report their Version 2 cartridge support in the welcome message when you ssh into the gear:
<screen>Note: Your application supports version 2 cartridges.</screen>
^ Based on https://github.com/ramr/nodejs-custom-version-openshift/issues/2
Closing this BZ.
The focus of the documentation team is going to shift from OpenShift v2 to v3, and only the remaining v2 doc BZs that feature actual errors in the docs will be worked on.
If there are any oppositions for any specific BZs, please contact me or the docs team.