show all pods
oc get pods
rsh into a pod, eg:
oc rsh mongodb-1-vs19d
start mongo as admin
mongo -u $MONGODB_USER -p $MONGODB_PASSWORD $MONGODB_DATABASE
get envars for one pod, eg:
oc env pods my-app-5-u0v5b --list
get envars for all pods
oc env pods --all --list
set envars for a deploymentconfig
oc env dc/my-app APP_FILE=wsgi/application
show services
oc get svc
see: https://docs.openshift.com/online/cli_reference/basic_cli_operations.html#oc-common-operations
copy a local mongodump to mongodb pod
oc rsync ~/Desktop/dump mongodb-1-vs49d:/var/lib/mongodb
mongorestore
oc rsh mongodb-1-vs19d
cd /var/lib/mongodb
mongorestore -u admin -p admin_password
insert an array of documents in a collection
var documents = [
{
"k1":"v1",
"k2":"v2",
"k3":"v3",
"k4": "v4",
"k5":"v5"
},
{
"k1":"v1",
"k2":"v2",
"k3":"v3",
"k4": "v4",
"k5":"v5"
}
]
use [desired_database]
for (i = 0; i < documents.length; i++) {
db.[desired_collection].insert(documents[i]);
}
db.[desired_collection].find().pretty()
log into mongodb
oc rsh mongodb-1-vs19d
mongo -u admin -p $MONGODB_ADMIN_PASSWORD admin
add a field to all documents in a collection
use [desired_database]
db.[desired_collecton].update({},{$set:{desired_key:"desired_value"}},{multi:true})
add a field to one document in a collection
use [desired_database]
db.[desired_collecton].update({key:"value"},{$set:{desired_key:"desired_value"}})