postgresql-ephemeral-template.json 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "postgresql-ephemeral",
  6. "creationTimestamp": null,
  7. "annotations": {
  8. "openshift.io/display-name": "PostgreSQL (Ephemeral)",
  9. "description": "PostgreSQL database service, without persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing",
  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-ephemeral-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": "DeploymentConfig",
  48. "apiVersion": "v1",
  49. "metadata": {
  50. "name": "${DATABASE_SERVICE_NAME}",
  51. "creationTimestamp": null
  52. },
  53. "spec": {
  54. "strategy": {
  55. "type": "Recreate"
  56. },
  57. "triggers": [
  58. {
  59. "type": "ImageChange",
  60. "imageChangeParams": {
  61. "automatic": true,
  62. "containerNames": [
  63. "postgresql"
  64. ],
  65. "from": {
  66. "kind": "ImageStreamTag",
  67. "name": "postgresql:${POSTGRESQL_VERSION}",
  68. "namespace": "${NAMESPACE}"
  69. },
  70. "lastTriggeredImage": ""
  71. }
  72. },
  73. {
  74. "type": "ConfigChange"
  75. }
  76. ],
  77. "replicas": 1,
  78. "selector": {
  79. "name": "${DATABASE_SERVICE_NAME}"
  80. },
  81. "template": {
  82. "metadata": {
  83. "creationTimestamp": null,
  84. "labels": {
  85. "name": "${DATABASE_SERVICE_NAME}"
  86. }
  87. },
  88. "spec": {
  89. "containers": [
  90. {
  91. "name": "postgresql",
  92. "image": " ",
  93. "ports": [
  94. {
  95. "containerPort": 5432,
  96. "protocol": "TCP"
  97. }
  98. ],
  99. "readinessProbe": {
  100. "timeoutSeconds": 1,
  101. "initialDelaySeconds": 5,
  102. "exec": {
  103. "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d $POSTGRESQL_DATABASE -c 'SELECT 1'"]
  104. }
  105. },
  106. "livenessProbe": {
  107. "timeoutSeconds": 1,
  108. "initialDelaySeconds": 30,
  109. "tcpSocket": {
  110. "port": 5432
  111. }
  112. },
  113. "env": [
  114. {
  115. "name": "POSTGRESQL_USER",
  116. "value": "${POSTGRESQL_USER}"
  117. },
  118. {
  119. "name": "POSTGRESQL_PASSWORD",
  120. "value": "${POSTGRESQL_PASSWORD}"
  121. },
  122. {
  123. "name": "POSTGRESQL_DATABASE",
  124. "value": "${POSTGRESQL_DATABASE}"
  125. }
  126. ],
  127. "resources": {
  128. "limits": {
  129. "memory": "${MEMORY_LIMIT}"
  130. }
  131. },
  132. "volumeMounts": [
  133. {
  134. "name": "${DATABASE_SERVICE_NAME}-data",
  135. "mountPath": "/var/lib/pgsql/data"
  136. }
  137. ],
  138. "terminationMessagePath": "/dev/termination-log",
  139. "imagePullPolicy": "IfNotPresent",
  140. "capabilities": {},
  141. "securityContext": {
  142. "capabilities": {},
  143. "privileged": false
  144. }
  145. }
  146. ],
  147. "volumes": [
  148. {
  149. "name": "${DATABASE_SERVICE_NAME}-data",
  150. "emptyDir": {
  151. "medium": ""
  152. }
  153. }
  154. ],
  155. "restartPolicy": "Always",
  156. "dnsPolicy": "ClusterFirst"
  157. }
  158. }
  159. },
  160. "status": {}
  161. }
  162. ],
  163. "parameters": [
  164. {
  165. "name": "MEMORY_LIMIT",
  166. "displayName": "Memory Limit",
  167. "description": "Maximum amount of memory the container can use.",
  168. "value": "512Mi"
  169. },
  170. {
  171. "name": "NAMESPACE",
  172. "displayName": "Namespace",
  173. "description": "The OpenShift Namespace where the ImageStream resides.",
  174. "value": "openshift"
  175. },
  176. {
  177. "name": "DATABASE_SERVICE_NAME",
  178. "displayName": "Database Service Name",
  179. "description": "The name of the OpenShift Service exposed for the database.",
  180. "value": "postgresql",
  181. "required": true
  182. },
  183. {
  184. "name": "POSTGRESQL_USER",
  185. "displayName": "PostgreSQL Connection Username",
  186. "description": "Username for PostgreSQL user that will be used for accessing the database.",
  187. "generate": "expression",
  188. "from": "user[A-Z0-9]{3}",
  189. "required": true
  190. },
  191. {
  192. "name": "POSTGRESQL_PASSWORD",
  193. "displayName": "PostgreSQL Connection Password",
  194. "description": "Password for the PostgreSQL connection user.",
  195. "generate": "expression",
  196. "from": "[a-zA-Z0-9]{16}",
  197. "required": true
  198. },
  199. {
  200. "name": "POSTGRESQL_DATABASE",
  201. "displayName": "PostgreSQL Database Name",
  202. "description": "Name of the PostgreSQL database accessed.",
  203. "value": "sampledb",
  204. "required": true
  205. },
  206. {
  207. "name": "POSTGRESQL_VERSION",
  208. "displayName": "Version of PostgreSQL Image",
  209. "description": "Version of PostgreSQL image to be used (9.2, 9.4, 9.5 or latest).",
  210. "value": "9.5",
  211. "required": true
  212. }
  213. ]
  214. }