postgresql-persistent-template.json 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1beta3",
  4. "metadata": {
  5. "name": "postgresql-persistent",
  6. "creationTimestamp": null,
  7. "annotations": {
  8. "description": "PostgreSQL database service, with persistent storage. Scaling to more than one replica is not supported",
  9. "iconClass": "icon-postgresql",
  10. "tags": "database,postgresql"
  11. }
  12. },
  13. "objects": [
  14. {
  15. "kind": "Service",
  16. "apiVersion": "v1beta3",
  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": "PersistentVolumeClaim",
  44. "apiVersion": "v1beta3",
  45. "metadata": {
  46. "name": "${DATABASE_SERVICE_NAME}"
  47. },
  48. "spec": {
  49. "accessModes": [
  50. "ReadWriteMany"
  51. ],
  52. "resources": {
  53. "requests": {
  54. "storage": "${VOLUME_CAPACITY}"
  55. }
  56. }
  57. }
  58. },
  59. {
  60. "kind": "DeploymentConfig",
  61. "apiVersion": "v1beta3",
  62. "metadata": {
  63. "name": "${DATABASE_SERVICE_NAME}",
  64. "creationTimestamp": null
  65. },
  66. "spec": {
  67. "strategy": {
  68. "type": "Recreate",
  69. "resources": {}
  70. },
  71. "triggers": [
  72. {
  73. "type": "ImageChange",
  74. "imageChangeParams": {
  75. "automatic": true,
  76. "containerNames": [
  77. "postgresql"
  78. ],
  79. "from": {
  80. "kind": "ImageStreamTag",
  81. "name": "postgresql:latest",
  82. "namespace": "openshift"
  83. },
  84. "lastTriggeredImage": ""
  85. }
  86. },
  87. {
  88. "type": "ConfigChange"
  89. }
  90. ],
  91. "replicas": 1,
  92. "selector": {
  93. "name": "${DATABASE_SERVICE_NAME}"
  94. },
  95. "template": {
  96. "metadata": {
  97. "creationTimestamp": null,
  98. "labels": {
  99. "name": "${DATABASE_SERVICE_NAME}"
  100. }
  101. },
  102. "spec": {
  103. "containers": [
  104. {
  105. "name": "postgresql",
  106. "image": "postgresql",
  107. "ports": [
  108. {
  109. "containerPort": 5432,
  110. "protocol": "TCP"
  111. }
  112. ],
  113. "env": [
  114. {
  115. "name": "POSTGRESQL_USER",
  116. "value": "${POSTGRESQL_USER}"
  117. },
  118. {
  119. "name": "POSTGRESQL_PASSWORD",
  120. "value": "${POSTGRESQL_PASSWORD}"
  121. },
  122. {
  123. "name": "POSTGRESQL_DATABASE",
  124. "value": "${POSTGRESQL_DATABASE}"
  125. }
  126. ],
  127. "resources": {},
  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. "persistentVolumeClaim": {
  147. "claimName": "postgresql"
  148. }
  149. }
  150. ],
  151. "restartPolicy": "Always",
  152. "dnsPolicy": "ClusterFirst"
  153. }
  154. }
  155. },
  156. "status": {}
  157. }
  158. ],
  159. "parameters": [
  160. {
  161. "name": "DATABASE_SERVICE_NAME",
  162. "description": "Database service name",
  163. "value": "mysql"
  164. },
  165. {
  166. "name": "POSTGRESQL_USER",
  167. "description": "Username for PostgreSQL user that will be used for accessing the database",
  168. "generate": "expression",
  169. "from": "user[A-Z0-9]{3}"
  170. },
  171. {
  172. "name": "POSTGRESQL_PASSWORD",
  173. "description": "Password for the PostgreSQL user",
  174. "generate": "expression",
  175. "from": "[a-zA-Z0-9]{16}"
  176. },
  177. {
  178. "name": "POSTGRESQL_DATABASE",
  179. "description": "Database name",
  180. "value": "sampledb"
  181. },
  182. {
  183. "name": "VOLUME_CAPACITY",
  184. "description": "Volume space available for data, e.g. 512Mi, 2Gi",
  185. "value": "512Mi"
  186. }
  187. ],
  188. "labels": {
  189. "template": "postgresql-persistent-template"
  190. }
  191. }