postgresql-persistent-template.json 7.8 KB

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