We can easily add a database pod into OpenShift wrapped in a service for other pods to access. OpenShift has supported templates to run containerized MySQL, MongoDB, and Postgres databases. Let’s try that now.
--> Deploying template mongodb-ephemeral in project openshift for "mongodb-ephemeral"
With parameters:
DATABASE_SERVICE_NAME=mongodb
MONGODB_USER=userIHJ # generated
MONGODB_PASSWORD=fCYLwSE3slxCqe0o # generated
MONGODB_DATABASE=sampledb
MONGODB_ADMIN_PASSWORD=CnbOj21pLKrjqBWP # generated
--> Creating resources ...
Service "mongodb" created
DeploymentConfig "mongodb" created
--> Success
Run 'oc status' to view your app.
Click "Browse" and filter for database, then click the mongodb-ephemeral builder image
We will accept the default values here. So just:
Scroll to the bottom and click "Create"
OpenShift will display a next steps page with details about what happened and what you can do next. Read that, then:
Click "Go to overview"
Summary
Now you have a runnning database generated from a supported OpenShift template using generated passwords and other env variables. We are using ephemeral databases in this lab, but you can also do persistent storage. However, we will save that topic for your homework or the topic of an advanced lab.