mongodb-persistent-template.json 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. You must have persistent volumes available in your cluster to use this template.",
  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. },
  70. "triggers": [
  71. {
  72. "type": "ImageChange",
  73. "imageChangeParams": {
  74. "automatic": true,
  75. "containerNames": [
  76. "mongodb"
  77. ],
  78. "from": {
  79. "kind": "ImageStreamTag",
  80. "name": "mongodb:latest",
  81. "namespace": "${NAMESPACE}"
  82. },
  83. "lastTriggeredImage": ""
  84. }
  85. },
  86. {
  87. "type": "ConfigChange"
  88. }
  89. ],
  90. "replicas": 1,
  91. "selector": {
  92. "name": "${DATABASE_SERVICE_NAME}"
  93. },
  94. "template": {
  95. "metadata": {
  96. "creationTimestamp": null,
  97. "labels": {
  98. "name": "${DATABASE_SERVICE_NAME}"
  99. }
  100. },
  101. "spec": {
  102. "containers": [
  103. {
  104. "name": "mongodb",
  105. "image": "mongodb",
  106. "ports": [
  107. {
  108. "containerPort": 27017,
  109. "protocol": "TCP"
  110. }
  111. ],
  112. "readinessProbe": {
  113. "timeoutSeconds": 1,
  114. "initialDelaySeconds": 3,
  115. "exec": {
  116. "command": [ "/bin/sh", "-i", "-c", "mongostat --host 127.0.0.1 -u admin -p $MONGODB_ADMIN_PASSWORD -n 1 --noheaders"]
  117. }
  118. },
  119. "livenessProbe": {
  120. "timeoutSeconds": 1,
  121. "initialDelaySeconds": 30,
  122. "tcpSocket": {
  123. "port": 27017
  124. }
  125. },
  126. "env": [
  127. {
  128. "name": "MONGODB_USER",
  129. "value": "${MONGODB_USER}"
  130. },
  131. {
  132. "name": "MONGODB_PASSWORD",
  133. "value": "${MONGODB_PASSWORD}"
  134. },
  135. {
  136. "name": "MONGODB_DATABASE",
  137. "value": "${MONGODB_DATABASE}"
  138. },
  139. {
  140. "name": "MONGODB_ADMIN_PASSWORD",
  141. "value": "${MONGODB_ADMIN_PASSWORD}"
  142. }
  143. ],
  144. "resources": {
  145. "limits": {
  146. "memory": "${MEMORY_LIMIT}"
  147. }
  148. },
  149. "volumeMounts": [
  150. {
  151. "name": "${DATABASE_SERVICE_NAME}-data",
  152. "mountPath": "/var/lib/mongodb/data"
  153. }
  154. ],
  155. "terminationMessagePath": "/dev/termination-log",
  156. "imagePullPolicy": "IfNotPresent",
  157. "capabilities": {},
  158. "securityContext": {
  159. "capabilities": {},
  160. "privileged": false
  161. }
  162. }
  163. ],
  164. "volumes": [
  165. {
  166. "name": "${DATABASE_SERVICE_NAME}-data",
  167. "persistentVolumeClaim": {
  168. "claimName": "${DATABASE_SERVICE_NAME}"
  169. }
  170. }
  171. ],
  172. "restartPolicy": "Always",
  173. "dnsPolicy": "ClusterFirst"
  174. }
  175. }
  176. },
  177. "status": {}
  178. }
  179. ],
  180. "parameters": [
  181. {
  182. "name": "MEMORY_LIMIT",
  183. "displayName": "Memory Limit",
  184. "description": "Maximum amount of memory the container can use.",
  185. "value": "512Mi"
  186. },
  187. {
  188. "name": "NAMESPACE",
  189. "displayName": "Namespace",
  190. "description": "The OpenShift Namespace where the ImageStream resides.",
  191. "value": "openshift"
  192. },
  193. {
  194. "name": "DATABASE_SERVICE_NAME",
  195. "displayName": "Database Service Name",
  196. "description": "The name of the OpenShift Service exposed for the database.",
  197. "value": "mongodb",
  198. "required": true
  199. },
  200. {
  201. "name": "MONGODB_USER",
  202. "displayName": "MongoDB User",
  203. "description": "Username for MongoDB user that will be used for accessing the database.",
  204. "generate": "expression",
  205. "from": "user[A-Z0-9]{3}",
  206. "required": true
  207. },
  208. {
  209. "name": "MONGODB_PASSWORD",
  210. "displayName": "MongoDB Password",
  211. "description": "Password for the MongoDB user.",
  212. "generate": "expression",
  213. "from": "[a-zA-Z0-9]{16}",
  214. "required": true
  215. },
  216. {
  217. "name": "MONGODB_DATABASE",
  218. "displayName": "MongoDB Database Name",
  219. "description": "Name of the MongoDB database accessed.",
  220. "value": "sampledb",
  221. "required": true
  222. },
  223. {
  224. "name": "MONGODB_ADMIN_PASSWORD",
  225. "displayName": "MongoDB Admin Password",
  226. "description": "Password for the database admin user.",
  227. "generate": "expression",
  228. "from": "[a-zA-Z0-9]{16}",
  229. "required": true
  230. },
  231. {
  232. "name": "VOLUME_CAPACITY",
  233. "displayName": "Volume Capacity",
  234. "description": "Volume space available for data, e.g. 512Mi, 2Gi.",
  235. "value": "1Gi",
  236. "required": true
  237. }
  238. ],
  239. "labels": {
  240. "template": "mongodb-persistent-template"
  241. }
  242. }