postgresql-persistent-template.json 6.4 KB

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