Skip to content

Instantly share code, notes, and snippets.

@ll911
Last active September 30, 2017 00:17
Show Gist options
  • Save ll911/4bca5e886fcccebc269f3f8799adf5d9 to your computer and use it in GitHub Desktop.
Save ll911/4bca5e886fcccebc269f3f8799adf5d9 to your computer and use it in GitHub Desktop.
mongodb-ocp-replicaset
{ "kind": "Template", "apiVersion": "v1", "metadata": { "name": "mongodb-replica-example", "annotations": { "description": "MongoDB Replication Example", "iconClass": "icon-mongodb", "tags": "database,mongodb,replication" } }, "labels": { "template": "mongodb-replica-example" }, "parameters": [ { "name": "MONGODB_USER", "description": "The username for MongoDB account to be created", "generate": "expression", "from": "[a-zA-Z0-9]{3}" }, { "name": "MONGODB_PASSWORD", "description": "Password for the MongoDB user account", "generate": "expression", "from": "[a-zA-Z0-9]{12}" }, { "name": "MONGODB_DATABASE", "description": "Name for the MongoDB database", "value": "sampledb" }, { "name": "MONGODB_ADMIN_PASSWORD", "description": "Password for the MongoDB admin user", "generate": "expression", "from": "[a-zA-Z0-9]{12}" }, { "name": "MONGODB_REPLICA_NAME", "description": "The name of the replica set", "value": "rs0" }, { "name": "MONGODB_SERVICE_NAME", "description": "The name of the MongoDB Service (used to DNS lookup)", "value": "mongodb" }, { "name": "MONGODB_KEYFILE_VALUE", "description": "The value of the MongoDB Key (see for details: https://docs.mongodb.org/v2.4/tutorial/generate-key-file/)", "generate": "expression", "from": "[a-zA-Z0-9]{255}" } ], "objects": [ { "kind": "Service", "apiVersion": "v1", "metadata": { "name": "${MONGODB_SERVICE_NAME}", "labels": { "name": "${MONGODB_SERVICE_NAME}" } }, "spec": { "ports": [ { "name": "mongodb", "port": 27017, "targetPort": 27017 } ], "selector": { "name": "mongodb-replica" }, "clusterIP": "None" } }, { "kind": "DeploymentConfig", "apiVersion": "v1", "metadata": { "name": "${MONGODB_SERVICE_NAME}" }, "spec": { "strategy": { "type": "Recreate", "recreateParams": { "post": { "failurePolicy": "Retry", "execNewPod": { "command": [ "run-mongod-replication", "initiate" ], "containerName": "mongodb", "env": [ { "name": "MONGODB_INITIAL_REPLICA_COUNT", "value": "3" } ] } } } }, "triggers": [ { "type": "ConfigChange" } ], "replicas": 3, "selector": { "name": "mongodb-replica" }, "template": { "metadata": { "labels": { "name": "mongodb-replica" } }, "spec": { "containers": [ { "name": "mongodb", "image": "openshift/mongodb-32-centos7", "args": [ "run-mongod-replication" ], "readinessProbe": { "tcpSocket": { "port": 27017 }, "initialDelaySeconds": 15, "timeoutSeconds": 1 }, "env": [ { "name": "MONGODB_USER", "value": "${MONGODB_USER}" }, { "name": "MONGODB_PASSWORD", "value": "${MONGODB_PASSWORD}" }, { "name": "MONGODB_DATABASE", "value": "${MONGODB_DATABASE}" }, { "name": "MONGODB_ADMIN_PASSWORD", "value": "${MONGODB_ADMIN_PASSWORD}" }, { "name": "MONGODB_REPLICA_NAME", "value": "${MONGODB_REPLICA_NAME}" }, { "name": "MONGODB_SERVICE_NAME", "value": "${MONGODB_SERVICE_NAME}" }, { "name": "MONGODB_KEYFILE_VALUE", "value": "${MONGODB_KEYFILE_VALUE}" } ], "ports": [ { "containerPort": 27017 } ] } ] } } } } ]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment