Skip to content

Instantly share code, notes, and snippets.

@jdart
Created May 3, 2016 18:17
Show Gist options
  • Save jdart/4f2b7e03eac1ecda26bf01f1b33cfca6 to your computer and use it in GitHub Desktop.
Save jdart/4f2b7e03eac1ecda26bf01f1b33cfca6 to your computer and use it in GitHub Desktop.
{
"kind": "Template",
"apiVersion": "v1",
"metadata": {
"name": "info",
"annotations": {
"description": "An example Rails application with a PostgreSQL database",
"tags": "instant-app,ruby,rails,postgresql",
"iconClass": "icon-ruby"
}
},
"labels": {
"template": "info"
},
"objects": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "info",
"annotations": {
"description": "Exposes and load balances the application pods"
}
},
"spec": {
"ports": [
{
"name": "web",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"name": "info"
}
}
},
{
"kind": "Route",
"apiVersion": "v1",
"metadata": {
"name": "info"
},
"spec": {
"host": "${APPLICATION_DOMAIN}",
"to": {
"kind": "Service",
"name": "info"
}
}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "postgresql",
"annotations": {
"description": "Keeps track of changes in the postgresql image"
}
}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "info",
"annotations": {
"description": "Keeps track of changes in the application image"
}
}
},
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "info",
"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": "ruby:2.2"
},
"env": [
{
"name": "DISABLE_ASSET_COMPILATION",
"value": "true"
}
]
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "info:latest"
}
},
"triggers": [
{
"type": "ImageChange"
},
{
"type": "ConfigChange"
},
{
"type": "GitHub",
"github": {
"secret": "${GITHUB_WEBHOOK_SECRET}"
}
}
]
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "info",
"annotations": {
"description": "Defines how to deploy the application server"
}
},
"spec": {
"strategy": {
"type": "Recreate",
"recreateParams": {
"pre": {
"failurePolicy": "Abort",
"execNewPod": {
"command": [
"./migrate-database.sh"
],
"containerName": "info"
}
}
}
},
"triggers": [
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"info"
],
"from": {
"kind": "ImageStreamTag",
"name": "info:latest"
}
}
},
{
"type": "ConfigChange"
}
],
"replicas": 1,
"selector": {
"name": "info"
},
"template": {
"metadata": {
"name": "info",
"labels": {
"name": "info"
}
},
"spec": {
"containers": [
{
"name": "info",
"image": "info",
"ports": [
{
"containerPort": 8080
}
],
"env": [
{
"name": "DATABASE_SERVICE_NAME",
"value": "${DATABASE_SERVICE_NAME}"
},
{
"name": "POSTGRESQL_USER",
"value": "${DATABASE_USER}"
},
{
"name": "POSTGRESQL_PASSWORD",
"value": "${DATABASE_PASSWORD}"
},
{
"name": "POSTGRESQL_DATABASE",
"value": "${DATABASE_NAME}"
},
{
"name": "SECRET_KEY_BASE",
"value": "${SECRET_KEY_BASE}"
},
{
"name": "POSTGRESQL_MAX_CONNECTIONS",
"value": "${POSTGRESQL_MAX_CONNECTIONS}"
},
{
"name": "POSTGRESQL_SHARED_BUFFERS",
"value": "${POSTGRESQL_SHARED_BUFFERS}"
},
{
"name": "SECRET_KEY_BASE",
"value": "${SECRET_KEY_BASE}"
},
{
"name": "APPLICATION_DOMAIN",
"value": "${APPLICATION_DOMAIN}"
},
{
"name": "APPLICATION_USER",
"value": "${APPLICATION_USER}"
},
{
"name": "APPLICATION_PASSWORD",
"value": "${APPLICATION_PASSWORD}"
},
{
"name": "RAILS_ENV",
"value": "${RAILS_ENV}"
}
]
}
]
}
}
}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "${DATABASE_SERVICE_NAME}",
"annotations": {
"description": "Exposes the database server"
}
},
"spec": {
"ports": [
{
"name": "postgresql",
"port": 5432,
"targetPort": 5432
}
],
"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": "ImageChange",
"imageChangeParams": {
"automatic": false,
"containerNames": [
"postgresql"
],
"from": {
"kind": "ImageStreamTag",
"namespace": "openshift",
"name": "postgresql:9.4"
}
}
},
{
"type": "ConfigChange"
}
],
"replicas": 1,
"selector": {
"name": "${DATABASE_SERVICE_NAME}"
},
"template": {
"metadata": {
"name": "${DATABASE_SERVICE_NAME}",
"labels": {
"name": "${DATABASE_SERVICE_NAME}"
}
},
"spec": {
"containers": [
{
"name": "postgresql",
"image": "postgresql",
"ports": [
{
"containerPort": 5432
}
],
"readinessProbe": {
"timeoutSeconds": 1,
"initialDelaySeconds": 5,
"exec": {
"command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d $POSTGRESQL_DATABASE -c 'SELECT 1'"]
}
},
"livenessProbe": {
"timeoutSeconds": 1,
"initialDelaySeconds": 30,
"tcpSocket": {
"port": 5432
}
},
"env": [
{
"name": "POSTGRESQL_USER",
"value": "${DATABASE_USER}"
},
{
"name": "POSTGRESQL_PASSWORD",
"value": "${DATABASE_PASSWORD}"
},
{
"name": "POSTGRESQL_DATABASE",
"value": "${DATABASE_NAME}"
},
{
"name": "POSTGRESQL_MAX_CONNECTIONS",
"value": "${POSTGRESQL_MAX_CONNECTIONS}"
},
{
"name": "POSTGRESQL_SHARED_BUFFERS",
"value": "${POSTGRESQL_SHARED_BUFFERS}"
}
],
"volumeMounts": [
{
"name": "${DATABASE_SERVICE_NAME}-data",
"mountPath": "/var/lib/pgsql/data"
}
],
"terminationMessagePath": "/dev/termination-log",
"imagePullPolicy": "IfNotPresent",
"capabilities": {},
"securityContext": {
"capabilities": {},
"privileged": false
}
}
],
"volumes": [
{
"name": "${DATABASE_SERVICE_NAME}-data",
"persistentVolumeClaim": {
"claimName": "${DATABASE_SERVICE_NAME}"
}
}
]
}
}
}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "${DATABASE_SERVICE_NAME}"
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "${VOLUME_CAPACITY}"
}
},
"persistentVolumeReclaimPolicy": "Recycle"
}
}
],
"parameters": [
{
"name": "SOURCE_REPOSITORY_URL",
"description": "The URL of the repository with your application source code",
"value": "https://github.com/openshift/rails-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 Rails service, if left blank a value will be defaulted.",
"value": ""
},
{
"name": "GITHUB_WEBHOOK_SECRET",
"description": "A secret string used to configure the GitHub webhook",
"generate": "expression",
"from": "[a-zA-Z0-9]{40}"
},
{
"name": "SECRET_KEY_BASE",
"description": "Your secret key for verifying the integrity of signed cookies",
"generate": "expression",
"from": "[a-z0-9]{127}"
},
{
"name": "APPLICATION_USER",
"description": "The application user that is used within the sample application to authorize access on pages",
"value": "openshift"
},
{
"name": "APPLICATION_PASSWORD",
"description": "The application password that is used within the sample application to authorize access on pages",
"value": "secret"
},
{
"name": "RAILS_ENV",
"description": "Environment under which the sample application will run. Could be set to production, development or test",
"value": "production"
},
{
"name": "DATABASE_SERVICE_NAME",
"description": "Database service name",
"value": "postgresql"
},
{
"name": "DATABASE_USER",
"description": "database username",
"generate": "expression",
"from": "user[A-Z0-9]{3}"
},
{
"name": "DATABASE_PASSWORD",
"description": "database password",
"generate": "expression",
"from": "[a-zA-Z0-9]{8}"
},
{
"name": "DATABASE_NAME",
"description": "database name",
"value": "root"
},
{
"name": "POSTGRESQL_MAX_CONNECTIONS",
"description": "database max connections",
"value": "100"
},
{
"name": "POSTGRESQL_SHARED_BUFFERS",
"description": "database shared buffers",
"value": "12MB"
},
{
"name": "VOLUME_CAPACITY",
"displayName": "Volume Capacity",
"description": "Volume space available for data, e.g. 512Mi, 2Gi.",
"value": "1Gi",
"required": true
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment