mongodb-persistent-template.json 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "mongodb-persistent",
  6. "creationTimestamp": null,
  7. "annotations": {
  8. "description": "MongoDB database service, with persistent storage. Scaling to more than one replica is not supported",
  9. "iconClass": "icon-mongodb",
  10. "tags": "database,mongodb"
  11. }
  12. },
  13. "objects": [
  14. {
  15. "kind": "Service",
  16. "apiVersion": "v1",
  17. "metadata": {
  18. "name": "${DATABASE_SERVICE_NAME}",
  19. "creationTimestamp": null
  20. },
  21. "spec": {
  22. "ports": [
  23. {
  24. "name": "mongo",
  25. "protocol": "TCP",
  26. "port": 27017,
  27. "targetPort": 27017,
  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": "v1",
  45. "metadata": {
  46. "name": "${DATABASE_SERVICE_NAME}"
  47. },
  48. "spec": {
  49. "accessModes": [
  50. "ReadWriteOnce"
  51. ],
  52. "resources": {
  53. "requests": {
  54. "storage": "${VOLUME_CAPACITY}"
  55. }
  56. }
  57. }
  58. },
  59. {
  60. "kind": "DeploymentConfig",
  61. "apiVersion": "v1",
  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. "mongodb"
  78. ],
  79. "from": {
  80. "kind": "ImageStreamTag",
  81. "name": "mongodb: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": "mongodb",
  106. "image": "mongodb",
  107. "readinessProbe": {
  108. "tcpSocket":{
  109. "port": 27017
  110. },
  111. "initialDelaySeconds": 15,
  112. "timeoutSeconds": 1
  113. },
  114. "ports": [
  115. {
  116. "containerPort": 27017,
  117. "protocol": "TCP"
  118. }
  119. ],
  120. "env": [
  121. {
  122. "name": "MONGODB_USER",
  123. "value": "${MONGODB_USER}"
  124. },
  125. {
  126. "name": "MONGODB_PASSWORD",
  127. "value": "${MONGODB_PASSWORD}"
  128. },
  129. {
  130. "name": "MONGODB_DATABASE",
  131. "value": "${MONGODB_DATABASE}"
  132. },
  133. {
  134. "name": "MONGODB_ADMIN_PASSWORD",
  135. "value": "${MONGODB_ADMIN_PASSWORD}"
  136. }
  137. ],
  138. "resources": {},
  139. "volumeMounts": [
  140. {
  141. "name": "${DATABASE_SERVICE_NAME}-data",
  142. "mountPath": "/var/lib/mongodb/data"
  143. }
  144. ],
  145. "terminationMessagePath": "/dev/termination-log",
  146. "imagePullPolicy": "IfNotPresent",
  147. "capabilities": {},
  148. "securityContext": {
  149. "capabilities": {},
  150. "privileged": false
  151. }
  152. }
  153. ],
  154. "volumes": [
  155. {
  156. "name": "${DATABASE_SERVICE_NAME}-data",
  157. "persistentVolumeClaim": {
  158. "claimName": "${DATABASE_SERVICE_NAME}"
  159. }
  160. }
  161. ],
  162. "restartPolicy": "Always",
  163. "dnsPolicy": "ClusterFirst"
  164. }
  165. }
  166. },
  167. "status": {}
  168. }
  169. ],
  170. "parameters": [
  171. {
  172. "name": "DATABASE_SERVICE_NAME",
  173. "description": "Database service name",
  174. "value": "mongodb",
  175. "required": true
  176. },
  177. {
  178. "name": "MONGODB_USER",
  179. "description": "Username for MongoDB user that will be used for accessing the database",
  180. "generate": "expression",
  181. "from": "user[A-Z0-9]{3}",
  182. "required": true
  183. },
  184. {
  185. "name": "MONGODB_PASSWORD",
  186. "description": "Password for the MongoDB user",
  187. "generate": "expression",
  188. "from": "[a-zA-Z0-9]{16}",
  189. "required": true
  190. },
  191. {
  192. "name": "MONGODB_DATABASE",
  193. "description": "Database name",
  194. "value": "sampledb",
  195. "required": true
  196. },
  197. {
  198. "name": "MONGODB_ADMIN_PASSWORD",
  199. "description": "Password for the database admin user",
  200. "generate": "expression",
  201. "from": "[a-zA-Z0-9]{16}",
  202. "required": true
  203. },
  204. {
  205. "name": "VOLUME_CAPACITY",
  206. "description": "Volume space available for data, e.g. 512Mi, 2Gi",
  207. "value": "512Mi",
  208. "required": true
  209. }
  210. ],
  211. "labels": {
  212. "template": "mongodb-persistent-template"
  213. }
  214. }