mongodb-persistent-template.json 9.5 KB

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