postgresql-ephemeral-template.json 8.2 KB

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