postgresql-persistent-template.json 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "postgresql-persistent",
  6. "creationTimestamp": null,
  7. "annotations": {
  8. "openshift.io/display-name": "PostgreSQL (Persistent)",
  9. "description": "PostgreSQL database service, with persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.\n\nNOTE: Scaling to more than one replica is not supported. You must have persistent volumes available in your cluster to use this template.",
  10. "iconClass": "icon-postgresql",
  11. "tags": "database,postgresql"
  12. }
  13. },
  14. "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n Username: ${POSTGRESQL_USER}\n Password: ${POSTGRESQL_PASSWORD}\n Database Name: ${POSTGRESQL_DATABASE}\n Connection URL: mysql://${DATABASE_SERVICE_NAME}:5432/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.",
  15. "labels": {
  16. "template": "postgresql-persistent-template"
  17. },
  18. "objects": [
  19. {
  20. "kind": "Service",
  21. "apiVersion": "v1",
  22. "metadata": {
  23. "name": "${DATABASE_SERVICE_NAME}",
  24. "creationTimestamp": null
  25. },
  26. "spec": {
  27. "ports": [
  28. {
  29. "name": "postgresql",
  30. "protocol": "TCP",
  31. "port": 5432,
  32. "targetPort": 5432,
  33. "nodePort": 0
  34. }
  35. ],
  36. "selector": {
  37. "name": "${DATABASE_SERVICE_NAME}"
  38. },
  39. "type": "ClusterIP",
  40. "sessionAffinity": "None"
  41. },
  42. "status": {
  43. "loadBalancer": {}
  44. }
  45. },
  46. {
  47. "kind": "PersistentVolumeClaim",
  48. "apiVersion": "v1",
  49. "metadata": {
  50. "name": "${DATABASE_SERVICE_NAME}"
  51. },
  52. "spec": {
  53. "accessModes": [
  54. "ReadWriteOnce"
  55. ],
  56. "resources": {
  57. "requests": {
  58. "storage": "${VOLUME_CAPACITY}"
  59. }
  60. }
  61. }
  62. },
  63. {
  64. "kind": "DeploymentConfig",
  65. "apiVersion": "v1",
  66. "metadata": {
  67. "name": "${DATABASE_SERVICE_NAME}",
  68. "creationTimestamp": null
  69. },
  70. "spec": {
  71. "strategy": {
  72. "type": "Recreate"
  73. },
  74. "triggers": [
  75. {
  76. "type": "ImageChange",
  77. "imageChangeParams": {
  78. "automatic": true,
  79. "containerNames": [
  80. "postgresql"
  81. ],
  82. "from": {
  83. "kind": "ImageStreamTag",
  84. "name": "postgresql:${POSTGRESQL_VERSION}",
  85. "namespace": "${NAMESPACE}"
  86. },
  87. "lastTriggeredImage": ""
  88. }
  89. },
  90. {
  91. "type": "ConfigChange"
  92. }
  93. ],
  94. "replicas": 1,
  95. "selector": {
  96. "name": "${DATABASE_SERVICE_NAME}"
  97. },
  98. "template": {
  99. "metadata": {
  100. "creationTimestamp": null,
  101. "labels": {
  102. "name": "${DATABASE_SERVICE_NAME}"
  103. }
  104. },
  105. "spec": {
  106. "containers": [
  107. {
  108. "name": "postgresql",
  109. "image": " ",
  110. "ports": [
  111. {
  112. "containerPort": 5432,
  113. "protocol": "TCP"
  114. }
  115. ],
  116. "readinessProbe": {
  117. "timeoutSeconds": 1,
  118. "initialDelaySeconds": 5,
  119. "exec": {
  120. "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d $POSTGRESQL_DATABASE -c 'SELECT 1'"]
  121. }
  122. },
  123. "livenessProbe": {
  124. "timeoutSeconds": 1,
  125. "initialDelaySeconds": 30,
  126. "tcpSocket": {
  127. "port": 5432
  128. }
  129. },
  130. "env": [
  131. {
  132. "name": "POSTGRESQL_USER",
  133. "value": "${POSTGRESQL_USER}"
  134. },
  135. {
  136. "name": "POSTGRESQL_PASSWORD",
  137. "value": "${POSTGRESQL_PASSWORD}"
  138. },
  139. {
  140. "name": "POSTGRESQL_DATABASE",
  141. "value": "${POSTGRESQL_DATABASE}"
  142. }
  143. ],
  144. "resources": {
  145. "limits": {
  146. "memory": "${MEMORY_LIMIT}"
  147. }
  148. },
  149. "volumeMounts": [
  150. {
  151. "name": "${DATABASE_SERVICE_NAME}-data",
  152. "mountPath": "/var/lib/pgsql/data"
  153. }
  154. ],
  155. "terminationMessagePath": "/dev/termination-log",
  156. "imagePullPolicy": "IfNotPresent",
  157. "capabilities": {},
  158. "securityContext": {
  159. "capabilities": {},
  160. "privileged": false
  161. }
  162. }
  163. ],
  164. "volumes": [
  165. {
  166. "name": "${DATABASE_SERVICE_NAME}-data",
  167. "persistentVolumeClaim": {
  168. "claimName": "${DATABASE_SERVICE_NAME}"
  169. }
  170. }
  171. ],
  172. "restartPolicy": "Always",
  173. "dnsPolicy": "ClusterFirst"
  174. }
  175. }
  176. },
  177. "status": {}
  178. }
  179. ],
  180. "parameters": [
  181. {
  182. "name": "MEMORY_LIMIT",
  183. "displayName": "Memory Limit",
  184. "description": "Maximum amount of memory the container can use.",
  185. "value": "512Mi"
  186. },
  187. {
  188. "name": "NAMESPACE",
  189. "displayName": "Namespace",
  190. "description": "The OpenShift Namespace where the ImageStream resides.",
  191. "value": "openshift"
  192. },
  193. {
  194. "name": "DATABASE_SERVICE_NAME",
  195. "displayName": "Database Service Name",
  196. "description": "The name of the OpenShift Service exposed for the database.",
  197. "value": "postgresql",
  198. "required": true
  199. },
  200. {
  201. "name": "POSTGRESQL_USER",
  202. "displayName": "PostgreSQL Connection Username",
  203. "description": "Username for PostgreSQL user that will be used for accessing the database.",
  204. "generate": "expression",
  205. "from": "user[A-Z0-9]{3}",
  206. "required": true
  207. },
  208. {
  209. "name": "POSTGRESQL_PASSWORD",
  210. "displayName": "PostgreSQL Connection Password",
  211. "description": "Password for the PostgreSQL connection user.",
  212. "generate": "expression",
  213. "from": "[a-zA-Z0-9]{16}",
  214. "required": true
  215. },
  216. {
  217. "name": "POSTGRESQL_DATABASE",
  218. "displayName": "PostgreSQL Database Name",
  219. "description": "Name of the PostgreSQL database accessed.",
  220. "value": "sampledb",
  221. "required": true
  222. },
  223. {
  224. "name": "VOLUME_CAPACITY",
  225. "displayName": "Volume Capacity",
  226. "description": "Volume space available for data, e.g. 512Mi, 2Gi.",
  227. "value": "1Gi",
  228. "required": true
  229. },
  230. {
  231. "name": "POSTGRESQL_VERSION",
  232. "displayName": "Version of PostgreSQL Image",
  233. "description": "Version of PostgreSQL image to be used (9.2, 9.4, 9.5 or latest).",
  234. "value": "9.5",
  235. "required": true
  236. }
  237. ]
  238. }