Merge pull request #12 from mnagy/add_database_template
Add database template
This commit is contained in:
commit
970919d0cc
2 changed files with 345 additions and 0 deletions
325
openshift/templates/nodejs-mongodb.json
Normal file
325
openshift/templates/nodejs-mongodb.json
Normal file
|
@ -0,0 +1,325 @@
|
|||
{
|
||||
"kind": "Template",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "nodejs-mongodb-example",
|
||||
"annotations": {
|
||||
"description": "An example Node.js application with a MongoDB database",
|
||||
"tags": "instant-app,nodejs,mongodb",
|
||||
"iconClass": "icon-nodejs"
|
||||
}
|
||||
},
|
||||
"labels": {
|
||||
"template": "nodejs-mongodb-example"
|
||||
},
|
||||
"objects": [
|
||||
{
|
||||
"kind": "Service",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "nodejs-frontend",
|
||||
"annotations": {
|
||||
"description": "Exposes and load balances the application pods"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"ports": [
|
||||
{
|
||||
"name": "web",
|
||||
"port": 8080,
|
||||
"targetPort": 8080
|
||||
}
|
||||
],
|
||||
"selector": {
|
||||
"name": "nodejs-frontend"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "Route",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "nodejs-route"
|
||||
},
|
||||
"spec": {
|
||||
"host": "${APPLICATION_DOMAIN}",
|
||||
"to": {
|
||||
"kind": "Service",
|
||||
"name": "nodejs-frontend"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "ImageStream",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "nodejs-example",
|
||||
"annotations": {
|
||||
"description": "Keeps track of changes in the application image"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "BuildConfig",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "nodejs-example",
|
||||
"annotations": {
|
||||
"description": "Defines how to build the application"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"source": {
|
||||
"type": "Git",
|
||||
"git": {
|
||||
"uri": "${SOURCE_REPOSITORY_URL}",
|
||||
"ref": "${SOURCE_REPOSITORY_REF}"
|
||||
},
|
||||
"contextDir": "${CONTEXT_DIR}"
|
||||
},
|
||||
"strategy": {
|
||||
"type": "Source",
|
||||
"sourceStrategy": {
|
||||
"from": {
|
||||
"kind": "ImageStreamTag",
|
||||
"namespace": "openshift",
|
||||
"name": "nodejs:0.10"
|
||||
}
|
||||
}
|
||||
},
|
||||
"output": {
|
||||
"to": {
|
||||
"kind": "ImageStreamTag",
|
||||
"name": "nodejs-example:latest"
|
||||
}
|
||||
},
|
||||
"triggers": [
|
||||
{
|
||||
"type": "ImageChange"
|
||||
},
|
||||
{
|
||||
"type": "GitHub",
|
||||
"github": {
|
||||
"secret": "${GITHUB_WEBHOOK_SECRET}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "DeploymentConfig",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "nodejs-frontend",
|
||||
"annotations": {
|
||||
"description": "Defines how to deploy the application server"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"strategy": {
|
||||
"type": "Rolling"
|
||||
},
|
||||
"triggers": [
|
||||
{
|
||||
"type": "ImageChange",
|
||||
"imageChangeParams": {
|
||||
"automatic": true,
|
||||
"containerNames": [
|
||||
"nodejs-example"
|
||||
],
|
||||
"from": {
|
||||
"kind": "ImageStreamTag",
|
||||
"name": "nodejs-example:latest"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ConfigChange"
|
||||
}
|
||||
],
|
||||
"replicas": 1,
|
||||
"selector": {
|
||||
"name": "nodejs-frontend"
|
||||
},
|
||||
"template": {
|
||||
"metadata": {
|
||||
"name": "nodejs-frontend",
|
||||
"labels": {
|
||||
"name": "nodejs-frontend"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"containers": [
|
||||
{
|
||||
"name": "nodejs-example",
|
||||
"image": "nodejs-example",
|
||||
"ports": [
|
||||
{
|
||||
"containerPort": 8080
|
||||
}
|
||||
],
|
||||
"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}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "Service",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "${DATABASE_SERVICE_NAME}",
|
||||
"annotations": {
|
||||
"description": "Exposes the database server"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"ports": [
|
||||
{
|
||||
"name": "mongodb",
|
||||
"port": 27017,
|
||||
"targetPort": 27017
|
||||
}
|
||||
],
|
||||
"selector": {
|
||||
"name": "${DATABASE_SERVICE_NAME}"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "DeploymentConfig",
|
||||
"apiVersion": "v1",
|
||||
"metadata": {
|
||||
"name": "${DATABASE_SERVICE_NAME}",
|
||||
"annotations": {
|
||||
"description": "Defines how to deploy the database"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"strategy": {
|
||||
"type": "Recreate"
|
||||
},
|
||||
"triggers": [
|
||||
{
|
||||
"type": "ConfigChange"
|
||||
}
|
||||
],
|
||||
"replicas": 1,
|
||||
"selector": {
|
||||
"name": "${DATABASE_SERVICE_NAME}"
|
||||
},
|
||||
"template": {
|
||||
"metadata": {
|
||||
"name": "${DATABASE_SERVICE_NAME}",
|
||||
"labels": {
|
||||
"name": "${DATABASE_SERVICE_NAME}"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"containers": [
|
||||
{
|
||||
"name": "mongodb",
|
||||
"image": "openshift/mongodb-24-centos7",
|
||||
"ports": [
|
||||
{
|
||||
"containerPort": 27017
|
||||
}
|
||||
],
|
||||
"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}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "SOURCE_REPOSITORY_URL",
|
||||
"description": "The URL of the repository with your application source code",
|
||||
"value": "https://github.com/openshift/nodejs-ex.git"
|
||||
},
|
||||
{
|
||||
"name": "SOURCE_REPOSITORY_REF",
|
||||
"description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch"
|
||||
},
|
||||
{
|
||||
"name": "CONTEXT_DIR",
|
||||
"description": "Set this to the relative path to your project if it is not in the root of your repository"
|
||||
},
|
||||
{
|
||||
"name": "APPLICATION_DOMAIN",
|
||||
"description": "The exposed hostname that will route to the Node.js service",
|
||||
"value": "nodejs-example.openshiftapps.com"
|
||||
},
|
||||
{
|
||||
"name": "GITHUB_WEBHOOK_SECRET",
|
||||
"description": "A secret string used to configure the GitHub webhook",
|
||||
"generate": "expression",
|
||||
"from": "[a-zA-Z0-9]{40}"
|
||||
},
|
||||
{
|
||||
"name": "DATABASE_SERVICE_NAME",
|
||||
"description": "Database service name",
|
||||
"value": "mongodb"
|
||||
},
|
||||
{
|
||||
"name": "MONGODB_USER",
|
||||
"description": "Username for MongoDB user that will be used for accessing the database",
|
||||
"generate": "expression",
|
||||
"from": "user[A-Z0-9]{3}"
|
||||
},
|
||||
{
|
||||
"name": "MONGODB_PASSWORD",
|
||||
"description": "Password for the MongoDB user",
|
||||
"generate": "expression",
|
||||
"from": "[a-zA-Z0-9]{16}"
|
||||
},
|
||||
{
|
||||
"name": "MONGODB_DATABASE",
|
||||
"description": "Database name",
|
||||
"value": "sampledb"
|
||||
},
|
||||
{
|
||||
"name": "MONGODB_ADMIN_PASSWORD",
|
||||
"description": "Password for the database admin user",
|
||||
"generate": "expression",
|
||||
"from": "[a-zA-Z0-9]{16}"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -189,6 +189,26 @@
|
|||
"description": "A secret string used to configure the GitHub webhook",
|
||||
"generate": "expression",
|
||||
"from": "[a-zA-Z0-9]{40}"
|
||||
},
|
||||
{
|
||||
"name": "DATABASE_SERVICE_NAME",
|
||||
"description": "Database service name"
|
||||
},
|
||||
{
|
||||
"name": "MONGODB_USER",
|
||||
"description": "Username for MongoDB user that will be used for accessing the database"
|
||||
},
|
||||
{
|
||||
"name": "MONGODB_PASSWORD",
|
||||
"description": "Password for the MongoDB user"
|
||||
},
|
||||
{
|
||||
"name": "MONGODB_DATABASE",
|
||||
"description": "Database name"
|
||||
},
|
||||
{
|
||||
"name": "MONGODB_ADMIN_PASSWORD",
|
||||
"description": "Password for the database admin user"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue