mongodb-persistent-template.json 9.0 KB

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