1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/openshift-developer-cli-connecting-the-database.adoc
2020-01-10 20:03:02 +00:00

55 lines
1.4 KiB
Plaintext

// Module included in the following assemblies:
//
// * cli_reference/openshift_developer_cli/creating-a-multicomponent-application-with-odo.adoc
// * cli_reference/openshift_developer_cli/creating-an-application-with-a-database.adoc
[id="Connecting-the-database-to-the-front-end-application_{context}"]
= Connecting the database to the front-end application
. Link the database to the front-end service:
+
----
$ odo link mongodb-persistent
✓ Service mongodb-persistent has been successfully linked from the component nodejs-nodejs-ex-mhbb
Following environment variables were added to nodejs-nodejs-ex-mhbb component:
- database_name
- password
- uri
- username
- admin_password
----
. See the environment variables of the application and the database in the Pod:
+
----
$ oc get pods
NAME READY STATUS RESTARTS AGE
mongodb-1-gsznc 1/1 Running 0 28m
nodejs-nodejs-ex-mhbb-app-4-vkn9l 1/1 Running 0 1m
$ oc rsh nodejs-nodejs-ex-mhbb-app-4-vkn9l
sh-4.3$ env
uri=mongodb://172.30.126.3:27017
password=dHIOpYneSkX3rTLn
database_name=sampledb
username=user43U
admin_password=NCn41tqmx7RIqmfv
sh-4.3$
----
. Open the URL in the browser and notice the database configuration in the bottom right:
+
----
$ odo url list
----
+
----
Request information
Page view count: 24
DB Connection Info:
Type: MongoDB
URL: mongodb://172.30.126.3:27017/sampledb
----