postgresql-ephemeral-template.json 5.7 KB

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