mongodb-ephemeral-template.json 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "mongodb-ephemeral",
  6. "creationTimestamp": null,
  7. "annotations": {
  8. "description": "MongoDB database service, without persistent storage. WARNING: Any data stored will be lost upon pod destruction. Only use this template for testing",
  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": "DeploymentConfig",
  44. "apiVersion": "v1",
  45. "metadata": {
  46. "name": "${DATABASE_SERVICE_NAME}",
  47. "creationTimestamp": null
  48. },
  49. "spec": {
  50. "strategy": {
  51. "type": "Recreate"
  52. },
  53. "triggers": [
  54. {
  55. "type": "ImageChange",
  56. "imageChangeParams": {
  57. "automatic": true,
  58. "containerNames": [
  59. "mongodb"
  60. ],
  61. "from": {
  62. "kind": "ImageStreamTag",
  63. "name": "mongodb:3.2",
  64. "namespace": "${NAMESPACE}"
  65. },
  66. "lastTriggeredImage": ""
  67. }
  68. },
  69. {
  70. "type": "ConfigChange"
  71. }
  72. ],
  73. "replicas": 1,
  74. "selector": {
  75. "name": "${DATABASE_SERVICE_NAME}"
  76. },
  77. "template": {
  78. "metadata": {
  79. "creationTimestamp": null,
  80. "labels": {
  81. "name": "${DATABASE_SERVICE_NAME}"
  82. }
  83. },
  84. "spec": {
  85. "containers": [
  86. {
  87. "name": "mongodb",
  88. "image": " ",
  89. "ports": [
  90. {
  91. "containerPort": 27017,
  92. "protocol": "TCP"
  93. }
  94. ],
  95. "readinessProbe": {
  96. "timeoutSeconds": 1,
  97. "initialDelaySeconds": 3,
  98. "exec": {
  99. "command": [ "/bin/sh", "-i", "-c", "mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p $MONGODB_PASSWORD --eval=\"quit()\""]
  100. }
  101. },
  102. "livenessProbe": {
  103. "timeoutSeconds": 1,
  104. "initialDelaySeconds": 30,
  105. "tcpSocket": {
  106. "port": 27017
  107. }
  108. },
  109. "env": [
  110. {
  111. "name": "MONGODB_USER",
  112. "value": "${MONGODB_USER}"
  113. },
  114. {
  115. "name": "MONGODB_PASSWORD",
  116. "value": "${MONGODB_PASSWORD}"
  117. },
  118. {
  119. "name": "MONGODB_DATABASE",
  120. "value": "${MONGODB_DATABASE}"
  121. },
  122. {
  123. "name": "MONGODB_ADMIN_PASSWORD",
  124. "value": "${MONGODB_ADMIN_PASSWORD}"
  125. }
  126. ],
  127. "resources": {
  128. "limits": {
  129. "memory": "${MEMORY_LIMIT}"
  130. }
  131. },
  132. "volumeMounts": [
  133. {
  134. "name": "${DATABASE_SERVICE_NAME}-data",
  135. "mountPath": "/var/lib/mongodb/data"
  136. }
  137. ],
  138. "terminationMessagePath": "/dev/termination-log",
  139. "imagePullPolicy": "IfNotPresent",
  140. "capabilities": {},
  141. "securityContext": {
  142. "capabilities": {},
  143. "privileged": false
  144. }
  145. }
  146. ],
  147. "volumes": [
  148. {
  149. "name": "${DATABASE_SERVICE_NAME}-data",
  150. "emptyDir": {
  151. "medium": ""
  152. }
  153. }
  154. ],
  155. "restartPolicy": "Always",
  156. "dnsPolicy": "ClusterFirst"
  157. }
  158. }
  159. },
  160. "status": {}
  161. }
  162. ],
  163. "parameters": [
  164. {
  165. "name": "MEMORY_LIMIT",
  166. "displayName": "Memory Limit",
  167. "description": "Maximum amount of memory the container can use.",
  168. "value": "512Mi"
  169. },
  170. {
  171. "name": "NAMESPACE",
  172. "displayName": "Namespace",
  173. "description": "The OpenShift Namespace where the ImageStream resides.",
  174. "value": "openshift"
  175. },
  176. {
  177. "name": "DATABASE_SERVICE_NAME",
  178. "displayName": "Database Service Name",
  179. "description": "The name of the OpenShift Service exposed for the database.",
  180. "value": "mongodb",
  181. "required": true
  182. },
  183. {
  184. "name": "MONGODB_USER",
  185. "displayName": "MongoDB Connection Username",
  186. "description": "Username for MongoDB user that will be used for accessing the database.",
  187. "generate": "expression",
  188. "from": "user[A-Z0-9]{3}",
  189. "required": true
  190. },
  191. {
  192. "name": "MONGODB_PASSWORD",
  193. "displayName": "MongoDB Connection Password",
  194. "description": "Password for the MongoDB connection user.",
  195. "generate": "expression",
  196. "from": "[a-zA-Z0-9]{16}",
  197. "required": true
  198. },
  199. {
  200. "name": "MONGODB_DATABASE",
  201. "displayName": "MongoDB Database Name",
  202. "description": "Name of the MongoDB database accessed.",
  203. "value": "sampledb",
  204. "required": true
  205. },
  206. {
  207. "name": "MONGODB_ADMIN_PASSWORD",
  208. "displayName": "MongoDB Admin Password",
  209. "description": "Password for the database admin user.",
  210. "generate": "expression",
  211. "from": "[a-zA-Z0-9]{16}",
  212. "required": true
  213. }
  214. ],
  215. "labels": {
  216. "template": "mongodb-ephemeral-template"
  217. },
  218. "message": "You can connect to the database using MongoDB connection URL mongodb://${MONGODB_USER}:${MONGODB_PASSWORD}@${DATABASE_SERVICE_NAME}/${MONGODB_DATABASE}"
  219. }