This is the documentation on External Database Environment Variables. It says,
Using an external service in your application is similar to using an internal service. Your application will be assigned environment variables for the service and the additional environment variables with the credentials described in the previous step. For example, a MySQL container receives the following environment variables:
EXTERNAL_MYSQL_SERVICE_SERVICE_HOST=<ip_address>
EXTERNAL_MYSQL_SERVICE_SERVICE_PORT=<port_number>
MYSQL_USERNAME=<mysql_username>
MYSQL_PASSWORD=<mysql_password>
MYSQL_DATABASE_NAME=<mysql_database>
This part is not clear - Your application will be assigned environment variables for the service.
How should the application be configured so that the environment variables for the service are assigned? I understand that, the ones defined in DeploymentConfig
will flow into the application in say NodeJS as process.env.MYSQL_USERNAME
, etc. I am not clear, how EXTERNAL_MYSQL_SERVICE_SERVICE_HOST
or EXTERNAL_MYSQL_SERVICE_SERVICE_PORT
will flow into.
From Step 1
of the link that you posted, if you create a Service object
oc expose deploymentconfig/<name>
This will automatically generate environment variables (https://docs.openshift.com/container-platform/3.11/dev_guide/environment_variables.html#automatically-added-environment-variables) for all pods in your namespace. (The environment variables may not be immediately available if the Service was added after your pods were already created...delete the pods to have them added on restart)