370 lines
10 KiB
JSON
370 lines
10 KiB
JSON
{
|
|
"kind": "Template",
|
|
"apiVersion": "v1",
|
|
"metadata": {
|
|
"name": "pg-replica-example",
|
|
"annotations": {
|
|
"description": "PostgreSQL Replication Example",
|
|
"iconClass": "icon-database",
|
|
"tags": "database,postgresql,replication"
|
|
}
|
|
},
|
|
"parameters": [
|
|
{
|
|
"name": "POSTGRESQL_MASTER_USER",
|
|
"description": "The username used for master-slave replication",
|
|
"value": "master",
|
|
"required": true
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_MASTER_PASSWORD",
|
|
"description": "The password for the PostgreSQL replication user",
|
|
"generate": "expression",
|
|
"from": "[a-zA-Z0-9]{12}",
|
|
"required": true
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_USER",
|
|
"description": "The username that clients will use to connect to PostgreSQL server",
|
|
"value": "user",
|
|
"required": true
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_PASSWORD",
|
|
"description": "The password for the PostgreSQL master user",
|
|
"generate": "expression",
|
|
"from": "[a-zA-Z0-9]{12}",
|
|
"required": true
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_DATABASE",
|
|
"description": "The name of the database that will be created",
|
|
"value": "userdb",
|
|
"required": true
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_ADMIN_PASSWORD",
|
|
"description": "The password for the PostgreSQL administrator",
|
|
"generate": "expression",
|
|
"from": "[a-zA-Z0-9]{12}",
|
|
"required": false
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_MASTER_SERVICE_NAME",
|
|
"description": "The name of the PostgreSQL Service (used to DNS lookup, default: 'postgresql-master')",
|
|
"value": "postgresql-master",
|
|
"required": true
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_SLAVE_SERVICE_NAME",
|
|
"description": "The name of the PostgreSQL Service (used to DNS lookup, default: 'postgresql-slave')",
|
|
"value": "postgresql-slave",
|
|
"required": true
|
|
},
|
|
{
|
|
"name": "VOLUME_CAPACITY",
|
|
"description": "Volume space available for data, e.g. 512Mi, 2Gi",
|
|
"value": "512Mi",
|
|
"required": true
|
|
},
|
|
{
|
|
"name": "IMAGESTREAMTAG",
|
|
"displayName": "ImageStreamTag",
|
|
"description": "The OpenShift ImageStreamTag to use for PostgreSQL.",
|
|
"value": "postgresql:9.6"
|
|
},
|
|
{
|
|
"name": "NAMESPACE",
|
|
"displayName": "Namespace",
|
|
"description": "The OpenShift Namespace where the ImageStream resides.",
|
|
"value": "openshift"
|
|
}
|
|
],
|
|
"objects": [
|
|
{
|
|
"kind": "PersistentVolumeClaim",
|
|
"apiVersion": "v1",
|
|
"metadata": {
|
|
"name": "postgresql-data-claim"
|
|
},
|
|
"spec": {
|
|
"accessModes": [
|
|
"ReadWriteOnce"
|
|
],
|
|
"resources": {
|
|
"requests": {
|
|
"storage": "${VOLUME_CAPACITY}"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"kind": "Service",
|
|
"apiVersion": "v1",
|
|
"metadata": {
|
|
"name": "${POSTGRESQL_MASTER_SERVICE_NAME}",
|
|
"labels": {
|
|
"name": "${POSTGRESQL_MASTER_SERVICE_NAME}"
|
|
}
|
|
},
|
|
"spec": {
|
|
"ports": [
|
|
{
|
|
"port": 5432,
|
|
"targetPort": 5432
|
|
}
|
|
],
|
|
"selector": {
|
|
"name": "${POSTGRESQL_MASTER_SERVICE_NAME}"
|
|
},
|
|
"clusterIP": "None"
|
|
}
|
|
},
|
|
{
|
|
"kind": "Service",
|
|
"apiVersion": "v1",
|
|
"metadata": {
|
|
"name": "${POSTGRESQL_SLAVE_SERVICE_NAME}",
|
|
"labels": {
|
|
"name": "${POSTGRESQL_SLAVE_SERVICE_NAME}"
|
|
}
|
|
},
|
|
"spec": {
|
|
"ports": [
|
|
{
|
|
"port": 5432,
|
|
"targetPort": 5432
|
|
}
|
|
],
|
|
"selector": {
|
|
"name": "${POSTGRESQL_SLAVE_SERVICE_NAME}"
|
|
},
|
|
"clusterIP": "None"
|
|
}
|
|
},
|
|
{
|
|
"kind": "DeploymentConfig",
|
|
"apiVersion": "v1",
|
|
"metadata": {
|
|
"name": "${POSTGRESQL_MASTER_SERVICE_NAME}"
|
|
},
|
|
"spec": {
|
|
"strategy": {
|
|
"type": "Recreate"
|
|
},
|
|
"triggers": [
|
|
{
|
|
"type": "ImageChange",
|
|
"imageChangeParams": {
|
|
"automatic": true,
|
|
"containerNames": [
|
|
"postgresql-master"
|
|
],
|
|
"from": {
|
|
"kind": "ImageStreamTag",
|
|
"name": "${IMAGESTREAMTAG}",
|
|
"namespace": "${NAMESPACE}"
|
|
},
|
|
"lastTriggeredImage": ""
|
|
}
|
|
},
|
|
{
|
|
"type": "ConfigChange"
|
|
}
|
|
],
|
|
"replicas": 1,
|
|
"selector": {
|
|
"name": "${POSTGRESQL_MASTER_SERVICE_NAME}"
|
|
},
|
|
"template": {
|
|
"metadata": {
|
|
"labels": {
|
|
"name": "${POSTGRESQL_MASTER_SERVICE_NAME}"
|
|
}
|
|
},
|
|
"spec": {
|
|
"volumes": [
|
|
{
|
|
"name": "postgresql-data",
|
|
"persistentVolumeClaim": {
|
|
"claimName": "postgresql-data-claim"
|
|
}
|
|
}
|
|
],
|
|
"containers": [
|
|
{
|
|
"name": "postgresql-master",
|
|
"image": " ",
|
|
"args": [
|
|
"run-postgresql-master"
|
|
],
|
|
"ports": [
|
|
{
|
|
"containerPort": 5432
|
|
}
|
|
],
|
|
"readinessProbe": {
|
|
"timeoutSeconds": 1,
|
|
"initialDelaySeconds": 5,
|
|
"exec": {
|
|
"command": [ "/usr/libexec/check-container" ]
|
|
}
|
|
},
|
|
"livenessProbe": {
|
|
"timeoutSeconds": 10,
|
|
"initialDelaySeconds": 120,
|
|
"exec": {
|
|
"command": [ "/usr/libexec/check-container", "--live" ]
|
|
}
|
|
},
|
|
"env": [
|
|
{
|
|
"name": "POSTGRESQL_MASTER_USER",
|
|
"value": "${POSTGRESQL_MASTER_USER}"
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_MASTER_PASSWORD",
|
|
"value": "${POSTGRESQL_MASTER_PASSWORD}"
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_USER",
|
|
"value": "${POSTGRESQL_USER}"
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_PASSWORD",
|
|
"value": "${POSTGRESQL_PASSWORD}"
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_DATABASE",
|
|
"value": "${POSTGRESQL_DATABASE}"
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_ADMIN_PASSWORD",
|
|
"value": "${POSTGRESQL_ADMIN_PASSWORD}"
|
|
}
|
|
],
|
|
"volumeMounts": [
|
|
{
|
|
"name": "postgresql-data",
|
|
"mountPath": "/var/lib/pgsql/data"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"kind": "DeploymentConfig",
|
|
"apiVersion": "v1",
|
|
"metadata": {
|
|
"name": "${POSTGRESQL_SLAVE_SERVICE_NAME}"
|
|
},
|
|
"spec": {
|
|
"strategy": {
|
|
"type": "Recreate"
|
|
},
|
|
"triggers": [
|
|
{
|
|
"type": "ImageChange",
|
|
"imageChangeParams": {
|
|
"automatic": true,
|
|
"containerNames": [
|
|
"postgresql-slave"
|
|
],
|
|
"from": {
|
|
"kind": "ImageStreamTag",
|
|
"name": "${IMAGESTREAMTAG}",
|
|
"namespace": "${NAMESPACE}"
|
|
},
|
|
"lastTriggeredImage": ""
|
|
}
|
|
},
|
|
{
|
|
"type": "ConfigChange"
|
|
}
|
|
],
|
|
"replicas": 1,
|
|
"selector": {
|
|
"name": "${POSTGRESQL_SLAVE_SERVICE_NAME}"
|
|
},
|
|
"template": {
|
|
"metadata": {
|
|
"labels": {
|
|
"name": "${POSTGRESQL_SLAVE_SERVICE_NAME}"
|
|
}
|
|
},
|
|
"spec": {
|
|
"volumes": [
|
|
{
|
|
"name": "postgresql-data",
|
|
"emptyDir": {}
|
|
}
|
|
],
|
|
"containers": [
|
|
{
|
|
"name": "postgresql-slave",
|
|
"image": " ",
|
|
"args": [
|
|
"run-postgresql-slave"
|
|
],
|
|
"ports": [
|
|
{
|
|
"containerPort": 5432
|
|
}
|
|
],
|
|
"readinessProbe": {
|
|
"timeoutSeconds": 1,
|
|
"initialDelaySeconds": 5,
|
|
"exec": {
|
|
"command": [ "/usr/libexec/check-container" ]
|
|
}
|
|
},
|
|
"livenessProbe": {
|
|
"timeoutSeconds": 10,
|
|
"initialDelaySeconds": 120,
|
|
"exec": {
|
|
"command": [ "/usr/libexec/check-container", "--live" ]
|
|
}
|
|
},
|
|
"env": [
|
|
{
|
|
"name": "POSTGRESQL_MASTER_SERVICE_NAME",
|
|
"value": "${POSTGRESQL_MASTER_SERVICE_NAME}"
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_MASTER_USER",
|
|
"value": "${POSTGRESQL_MASTER_USER}"
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_MASTER_PASSWORD",
|
|
"value": "${POSTGRESQL_MASTER_PASSWORD}"
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_USER",
|
|
"value": "${POSTGRESQL_USER}"
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_PASSWORD",
|
|
"value": "${POSTGRESQL_PASSWORD}"
|
|
},
|
|
{
|
|
"name": "POSTGRESQL_DATABASE",
|
|
"value": "${POSTGRESQL_DATABASE}"
|
|
}
|
|
],
|
|
"volumeMounts": [
|
|
{
|
|
"name": "postgresql-data",
|
|
"mountPath": "/var/lib/pgsql/data"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|