postgresql-persistent-template.json 8.8 KB

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