postgresql-persistent-template.json 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "postgresql-persistent",
  6. "creationTimestamp": null,
  7. "annotations": {
  8. "openshift.io/display-name": "PostgreSQL (Persistent)",
  9. "description": "PostgreSQL database service, with persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/postgresql-container/blob/master/9.5.\n\nNOTE: Scaling to more than one replica is not supported. You must have persistent volumes available in your cluster to use this template.",
  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 stored on persistent storage. 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-persistent-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": "PersistentVolumeClaim",
  63. "apiVersion": "v1",
  64. "metadata": {
  65. "name": "${DATABASE_SERVICE_NAME}"
  66. },
  67. "spec": {
  68. "accessModes": [
  69. "ReadWriteOnce"
  70. ],
  71. "resources": {
  72. "requests": {
  73. "storage": "${VOLUME_CAPACITY}"
  74. }
  75. }
  76. }
  77. },
  78. {
  79. "kind": "DeploymentConfig",
  80. "apiVersion": "v1",
  81. "metadata": {
  82. "name": "${DATABASE_SERVICE_NAME}",
  83. "creationTimestamp": null
  84. },
  85. "spec": {
  86. "strategy": {
  87. "type": "Recreate"
  88. },
  89. "triggers": [
  90. {
  91. "type": "ImageChange",
  92. "imageChangeParams": {
  93. "automatic": true,
  94. "containerNames": [
  95. "postgresql"
  96. ],
  97. "from": {
  98. "kind": "ImageStreamTag",
  99. "name": "postgresql:${POSTGRESQL_VERSION}",
  100. "namespace": "${NAMESPACE}"
  101. },
  102. "lastTriggeredImage": ""
  103. }
  104. },
  105. {
  106. "type": "ConfigChange"
  107. }
  108. ],
  109. "replicas": 1,
  110. "selector": {
  111. "name": "${DATABASE_SERVICE_NAME}"
  112. },
  113. "template": {
  114. "metadata": {
  115. "creationTimestamp": null,
  116. "labels": {
  117. "name": "${DATABASE_SERVICE_NAME}"
  118. }
  119. },
  120. "spec": {
  121. "containers": [
  122. {
  123. "name": "postgresql",
  124. "image": " ",
  125. "ports": [
  126. {
  127. "containerPort": 5432,
  128. "protocol": "TCP"
  129. }
  130. ],
  131. "readinessProbe": {
  132. "timeoutSeconds": 1,
  133. "initialDelaySeconds": 5,
  134. "exec": {
  135. "command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d $POSTGRESQL_DATABASE -c 'SELECT 1'"]
  136. }
  137. },
  138. "livenessProbe": {
  139. "timeoutSeconds": 1,
  140. "initialDelaySeconds": 30,
  141. "tcpSocket": {
  142. "port": 5432
  143. }
  144. },
  145. "env": [
  146. {
  147. "name": "POSTGRESQL_USER",
  148. "valueFrom": {
  149. "secretKeyRef" : {
  150. "name" : "${DATABASE_SERVICE_NAME}",
  151. "key" : "database-user"
  152. }
  153. }
  154. },
  155. {
  156. "name": "POSTGRESQL_PASSWORD",
  157. "valueFrom": {
  158. "secretKeyRef" : {
  159. "name" : "${DATABASE_SERVICE_NAME}",
  160. "key" : "database-password"
  161. }
  162. }
  163. },
  164. {
  165. "name": "POSTGRESQL_DATABASE",
  166. "value": "${POSTGRESQL_DATABASE}"
  167. }
  168. ],
  169. "resources": {
  170. "limits": {
  171. "memory": "${MEMORY_LIMIT}"
  172. }
  173. },
  174. "volumeMounts": [
  175. {
  176. "name": "${DATABASE_SERVICE_NAME}-data",
  177. "mountPath": "/var/lib/pgsql/data"
  178. }
  179. ],
  180. "terminationMessagePath": "/dev/termination-log",
  181. "imagePullPolicy": "IfNotPresent",
  182. "capabilities": {},
  183. "securityContext": {
  184. "capabilities": {},
  185. "privileged": false
  186. }
  187. }
  188. ],
  189. "volumes": [
  190. {
  191. "name": "${DATABASE_SERVICE_NAME}-data",
  192. "persistentVolumeClaim": {
  193. "claimName": "${DATABASE_SERVICE_NAME}"
  194. }
  195. }
  196. ],
  197. "restartPolicy": "Always",
  198. "dnsPolicy": "ClusterFirst"
  199. }
  200. }
  201. },
  202. "status": {}
  203. }
  204. ],
  205. "parameters": [
  206. {
  207. "name": "MEMORY_LIMIT",
  208. "displayName": "Memory Limit",
  209. "description": "Maximum amount of memory the container can use.",
  210. "value": "512Mi",
  211. "required": true
  212. },
  213. {
  214. "name": "NAMESPACE",
  215. "displayName": "Namespace",
  216. "description": "The OpenShift Namespace where the ImageStream resides.",
  217. "value": "openshift"
  218. },
  219. {
  220. "name": "DATABASE_SERVICE_NAME",
  221. "displayName": "Database Service Name",
  222. "description": "The name of the OpenShift Service exposed for the database.",
  223. "value": "postgresql",
  224. "required": true
  225. },
  226. {
  227. "name": "POSTGRESQL_USER",
  228. "displayName": "PostgreSQL Connection Username",
  229. "description": "Username for PostgreSQL user that will be used for accessing the database.",
  230. "generate": "expression",
  231. "from": "user[A-Z0-9]{3}",
  232. "required": true
  233. },
  234. {
  235. "name": "POSTGRESQL_PASSWORD",
  236. "displayName": "PostgreSQL Connection Password",
  237. "description": "Password for the PostgreSQL connection user.",
  238. "generate": "expression",
  239. "from": "[a-zA-Z0-9]{16}",
  240. "required": true
  241. },
  242. {
  243. "name": "POSTGRESQL_DATABASE",
  244. "displayName": "PostgreSQL Database Name",
  245. "description": "Name of the PostgreSQL database accessed.",
  246. "value": "sampledb",
  247. "required": true
  248. },
  249. {
  250. "name": "VOLUME_CAPACITY",
  251. "displayName": "Volume Capacity",
  252. "description": "Volume space available for data, e.g. 512Mi, 2Gi.",
  253. "value": "1Gi",
  254. "required": true
  255. },
  256. {
  257. "name": "POSTGRESQL_VERSION",
  258. "displayName": "Version of PostgreSQL Image",
  259. "description": "Version of PostgreSQL image to be used (9.2, 9.4, 9.5 or latest).",
  260. "value": "9.5",
  261. "required": true
  262. }
  263. ]
  264. }