postgresql-ephemeral-template.json 7.2 KB

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