mongodb-persistent-template.json 8.5 KB

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