mongodb-persistent-template.json 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "mongodb-persistent",
  6. "creationTimestamp": null,
  7. "annotations": {
  8. "openshift.io/display-name": "MongoDB (Persistent)",
  9. "description": "MongoDB database service, with persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/mongodb-container/blob/master/3.2/README.md.\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-mongodb",
  11. "tags": "database,mongodb"
  12. }
  13. },
  14. "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n Username: ${MONGODB_USER}\n Password: ${MONGODB_PASSWORD}\n Database Name: ${MONGODB_DATABASE}\n Connection URL: mongodb://${MONGODB_USER}:${MONGODB_PASSWORD}@${DATABASE_SERVICE_NAME}/${MONGODB_DATABASE}\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/mongodb-container/blob/master/3.2/README.md.",
  15. "labels": {
  16. "template": "mongodb-persistent-template"
  17. },
  18. "objects": [
  19. {
  20. "kind": "Service",
  21. "apiVersion": "v1",
  22. "metadata": {
  23. "name": "${DATABASE_SERVICE_NAME}",
  24. "creationTimestamp": null
  25. },
  26. "spec": {
  27. "ports": [
  28. {
  29. "name": "mongo",
  30. "protocol": "TCP",
  31. "port": 27017,
  32. "targetPort": 27017,
  33. "nodePort": 0
  34. }
  35. ],
  36. "selector": {
  37. "name": "${DATABASE_SERVICE_NAME}"
  38. },
  39. "type": "ClusterIP",
  40. "sessionAffinity": "None"
  41. },
  42. "status": {
  43. "loadBalancer": {}
  44. }
  45. },
  46. {
  47. "kind": "PersistentVolumeClaim",
  48. "apiVersion": "v1",
  49. "metadata": {
  50. "name": "${DATABASE_SERVICE_NAME}"
  51. },
  52. "spec": {
  53. "accessModes": [
  54. "ReadWriteOnce"
  55. ],
  56. "resources": {
  57. "requests": {
  58. "storage": "${VOLUME_CAPACITY}"
  59. }
  60. }
  61. }
  62. },
  63. {
  64. "kind": "DeploymentConfig",
  65. "apiVersion": "v1",
  66. "metadata": {
  67. "name": "${DATABASE_SERVICE_NAME}",
  68. "creationTimestamp": null
  69. },
  70. "spec": {
  71. "strategy": {
  72. "type": "Recreate"
  73. },
  74. "triggers": [
  75. {
  76. "type": "ImageChange",
  77. "imageChangeParams": {
  78. "automatic": true,
  79. "containerNames": [
  80. "mongodb"
  81. ],
  82. "from": {
  83. "kind": "ImageStreamTag",
  84. "name": "mongodb:${MONGODB_VERSION}",
  85. "namespace": "${NAMESPACE}"
  86. },
  87. "lastTriggeredImage": ""
  88. }
  89. },
  90. {
  91. "type": "ConfigChange"
  92. }
  93. ],
  94. "replicas": 1,
  95. "selector": {
  96. "name": "${DATABASE_SERVICE_NAME}"
  97. },
  98. "template": {
  99. "metadata": {
  100. "creationTimestamp": null,
  101. "labels": {
  102. "name": "${DATABASE_SERVICE_NAME}"
  103. }
  104. },
  105. "spec": {
  106. "containers": [
  107. {
  108. "name": "mongodb",
  109. "image": " ",
  110. "ports": [
  111. {
  112. "containerPort": 27017,
  113. "protocol": "TCP"
  114. }
  115. ],
  116. "readinessProbe": {
  117. "timeoutSeconds": 1,
  118. "initialDelaySeconds": 3,
  119. "exec": {
  120. "command": [ "/bin/sh", "-i", "-c", "mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p $MONGODB_PASSWORD --eval=\"quit()\""]
  121. }
  122. },
  123. "livenessProbe": {
  124. "timeoutSeconds": 1,
  125. "initialDelaySeconds": 30,
  126. "tcpSocket": {
  127. "port": 27017
  128. }
  129. },
  130. "env": [
  131. {
  132. "name": "MONGODB_USER",
  133. "value": "${MONGODB_USER}"
  134. },
  135. {
  136. "name": "MONGODB_PASSWORD",
  137. "value": "${MONGODB_PASSWORD}"
  138. },
  139. {
  140. "name": "MONGODB_DATABASE",
  141. "value": "${MONGODB_DATABASE}"
  142. },
  143. {
  144. "name": "MONGODB_ADMIN_PASSWORD",
  145. "value": "${MONGODB_ADMIN_PASSWORD}"
  146. }
  147. ],
  148. "resources": {
  149. "limits": {
  150. "memory": "${MEMORY_LIMIT}"
  151. }
  152. },
  153. "volumeMounts": [
  154. {
  155. "name": "${DATABASE_SERVICE_NAME}-data",
  156. "mountPath": "/var/lib/mongodb/data"
  157. }
  158. ],
  159. "terminationMessagePath": "/dev/termination-log",
  160. "imagePullPolicy": "IfNotPresent",
  161. "capabilities": {},
  162. "securityContext": {
  163. "capabilities": {},
  164. "privileged": false
  165. }
  166. }
  167. ],
  168. "volumes": [
  169. {
  170. "name": "${DATABASE_SERVICE_NAME}-data",
  171. "persistentVolumeClaim": {
  172. "claimName": "${DATABASE_SERVICE_NAME}"
  173. }
  174. }
  175. ],
  176. "restartPolicy": "Always",
  177. "dnsPolicy": "ClusterFirst"
  178. }
  179. }
  180. },
  181. "status": {}
  182. }
  183. ],
  184. "parameters": [
  185. {
  186. "name": "MEMORY_LIMIT",
  187. "displayName": "Memory Limit",
  188. "description": "Maximum amount of memory the container can use.",
  189. "value": "512Mi"
  190. },
  191. {
  192. "name": "NAMESPACE",
  193. "displayName": "Namespace",
  194. "description": "The OpenShift Namespace where the ImageStream resides.",
  195. "value": "openshift"
  196. },
  197. {
  198. "name": "DATABASE_SERVICE_NAME",
  199. "displayName": "Database Service Name",
  200. "description": "The name of the OpenShift Service exposed for the database.",
  201. "value": "mongodb",
  202. "required": true
  203. },
  204. {
  205. "name": "MONGODB_USER",
  206. "displayName": "MongoDB Connection Username",
  207. "description": "Username for MongoDB user that will be used for accessing the database.",
  208. "generate": "expression",
  209. "from": "user[A-Z0-9]{3}",
  210. "required": true
  211. },
  212. {
  213. "name": "MONGODB_PASSWORD",
  214. "displayName": "MongoDB Connection Password",
  215. "description": "Password for the MongoDB connection user.",
  216. "generate": "expression",
  217. "from": "[a-zA-Z0-9]{16}",
  218. "required": true
  219. },
  220. {
  221. "name": "MONGODB_DATABASE",
  222. "displayName": "MongoDB Database Name",
  223. "description": "Name of the MongoDB database accessed.",
  224. "value": "sampledb",
  225. "required": true
  226. },
  227. {
  228. "name": "MONGODB_ADMIN_PASSWORD",
  229. "displayName": "MongoDB Admin Password",
  230. "description": "Password for the database admin user.",
  231. "generate": "expression",
  232. "from": "[a-zA-Z0-9]{16}",
  233. "required": true
  234. },
  235. {
  236. "name": "VOLUME_CAPACITY",
  237. "displayName": "Volume Capacity",
  238. "description": "Volume space available for data, e.g. 512Mi, 2Gi.",
  239. "value": "1Gi",
  240. "required": true
  241. },
  242. {
  243. "name": "MONGODB_VERSION",
  244. "displayName": "Version of MongoDB Image",
  245. "description": "Version of MongoDB image to be used (2.4, 2.6, 3.2 or latest).",
  246. "value": "3.2",
  247. "required": true
  248. }
  249. ]
  250. }