postgresql-ephemeral-template.json 7.9 KB

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