mongodb-persistent-template.json 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "mongodb-persistent",
  6. "annotations": {
  7. "openshift.io/display-name": "MongoDB (Persistent)",
  8. "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.",
  9. "iconClass": "icon-mongodb",
  10. "tags": "database,mongodb",
  11. "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.",
  12. "openshift.io/provider-display-name": "Red Hat, Inc.",
  13. "openshift.io/documentation-url": "https://docs.openshift.org/latest/using_images/db_images/mongodb.html",
  14. "openshift.io/support-url": "https://access.redhat.com"
  15. }
  16. },
  17. "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.",
  18. "labels": {
  19. "template": "mongodb-persistent-template"
  20. },
  21. "objects": [
  22. {
  23. "kind": "Secret",
  24. "apiVersion": "v1",
  25. "metadata": {
  26. "name": "${DATABASE_SERVICE_NAME}",
  27. "annotations": {
  28. "template.openshift.io/expose-username": "{.data['database-user']}",
  29. "template.openshift.io/expose-password": "{.data['database-password']}",
  30. "template.openshift.io/expose-admin_password": "{.data['database-admin-password']}",
  31. "template.openshift.io/expose-database_name": "{.data['database-name']}"
  32. }
  33. },
  34. "stringData" : {
  35. "database-user" : "${MONGODB_USER}",
  36. "database-password" : "${MONGODB_PASSWORD}",
  37. "database-admin-password" : "${MONGODB_ADMIN_PASSWORD}",
  38. "database-name" : "${MONGODB_DATABASE}"
  39. }
  40. },
  41. {
  42. "kind": "Service",
  43. "apiVersion": "v1",
  44. "metadata": {
  45. "name": "${DATABASE_SERVICE_NAME}",
  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. "annotations": {
  93. "template.alpha.openshift.io/wait-for-ready": "true"
  94. }
  95. },
  96. "spec": {
  97. "strategy": {
  98. "type": "Recreate"
  99. },
  100. "triggers": [
  101. {
  102. "type": "ImageChange",
  103. "imageChangeParams": {
  104. "automatic": true,
  105. "containerNames": [
  106. "mongodb"
  107. ],
  108. "from": {
  109. "kind": "ImageStreamTag",
  110. "name": "mongodb:${MONGODB_VERSION}",
  111. "namespace": "${NAMESPACE}"
  112. },
  113. "lastTriggeredImage": ""
  114. }
  115. },
  116. {
  117. "type": "ConfigChange"
  118. }
  119. ],
  120. "replicas": 1,
  121. "selector": {
  122. "name": "${DATABASE_SERVICE_NAME}"
  123. },
  124. "template": {
  125. "metadata": {
  126. "labels": {
  127. "name": "${DATABASE_SERVICE_NAME}"
  128. }
  129. },
  130. "spec": {
  131. "containers": [
  132. {
  133. "name": "mongodb",
  134. "image": " ",
  135. "ports": [
  136. {
  137. "containerPort": 27017,
  138. "protocol": "TCP"
  139. }
  140. ],
  141. "readinessProbe": {
  142. "timeoutSeconds": 1,
  143. "initialDelaySeconds": 3,
  144. "exec": {
  145. "command": [ "/bin/sh", "-i", "-c", "mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p $MONGODB_PASSWORD --eval=\"quit()\""]
  146. }
  147. },
  148. "livenessProbe": {
  149. "timeoutSeconds": 1,
  150. "initialDelaySeconds": 30,
  151. "tcpSocket": {
  152. "port": 27017
  153. }
  154. },
  155. "env": [
  156. {
  157. "name": "MONGODB_USER",
  158. "valueFrom": {
  159. "secretKeyRef" : {
  160. "name" : "${DATABASE_SERVICE_NAME}",
  161. "key" : "database-user"
  162. }
  163. }
  164. },
  165. {
  166. "name": "MONGODB_PASSWORD",
  167. "valueFrom": {
  168. "secretKeyRef" : {
  169. "name" : "${DATABASE_SERVICE_NAME}",
  170. "key" : "database-password"
  171. }
  172. }
  173. },
  174. {
  175. "name": "MONGODB_ADMIN_PASSWORD",
  176. "valueFrom": {
  177. "secretKeyRef" : {
  178. "name" : "${DATABASE_SERVICE_NAME}",
  179. "key" : "database-admin-password"
  180. }
  181. }
  182. },
  183. {
  184. "name": "MONGODB_DATABASE",
  185. "valueFrom": {
  186. "secretKeyRef" : {
  187. "name" : "${DATABASE_SERVICE_NAME}",
  188. "key" : "database-name"
  189. }
  190. }
  191. }
  192. ],
  193. "resources": {
  194. "limits": {
  195. "memory": "${MEMORY_LIMIT}"
  196. }
  197. },
  198. "volumeMounts": [
  199. {
  200. "name": "${DATABASE_SERVICE_NAME}-data",
  201. "mountPath": "/var/lib/mongodb/data"
  202. }
  203. ],
  204. "terminationMessagePath": "/dev/termination-log",
  205. "imagePullPolicy": "IfNotPresent",
  206. "capabilities": {},
  207. "securityContext": {
  208. "capabilities": {},
  209. "privileged": false
  210. }
  211. }
  212. ],
  213. "volumes": [
  214. {
  215. "name": "${DATABASE_SERVICE_NAME}-data",
  216. "persistentVolumeClaim": {
  217. "claimName": "${DATABASE_SERVICE_NAME}"
  218. }
  219. }
  220. ],
  221. "restartPolicy": "Always",
  222. "dnsPolicy": "ClusterFirst"
  223. }
  224. }
  225. },
  226. "status": {}
  227. }
  228. ],
  229. "parameters": [
  230. {
  231. "name": "MEMORY_LIMIT",
  232. "displayName": "Memory Limit",
  233. "description": "Maximum amount of memory the container can use.",
  234. "value": "512Mi",
  235. "required": true
  236. },
  237. {
  238. "name": "NAMESPACE",
  239. "displayName": "Namespace",
  240. "description": "The OpenShift Namespace where the ImageStream resides.",
  241. "value": "openshift"
  242. },
  243. {
  244. "name": "DATABASE_SERVICE_NAME",
  245. "displayName": "Database Service Name",
  246. "description": "The name of the OpenShift Service exposed for the database.",
  247. "value": "mongodb",
  248. "required": true
  249. },
  250. {
  251. "name": "MONGODB_USER",
  252. "displayName": "MongoDB Connection Username",
  253. "description": "Username for MongoDB user that will be used for accessing the database.",
  254. "generate": "expression",
  255. "from": "user[A-Z0-9]{3}",
  256. "required": true
  257. },
  258. {
  259. "name": "MONGODB_PASSWORD",
  260. "displayName": "MongoDB Connection Password",
  261. "description": "Password for the MongoDB connection user.",
  262. "generate": "expression",
  263. "from": "[a-zA-Z0-9]{16}",
  264. "required": true
  265. },
  266. {
  267. "name": "MONGODB_DATABASE",
  268. "displayName": "MongoDB Database Name",
  269. "description": "Name of the MongoDB database accessed.",
  270. "value": "sampledb",
  271. "required": true
  272. },
  273. {
  274. "name": "MONGODB_ADMIN_PASSWORD",
  275. "displayName": "MongoDB Admin Password",
  276. "description": "Password for the database admin user.",
  277. "generate": "expression",
  278. "from": "[a-zA-Z0-9]{16}",
  279. "required": true
  280. },
  281. {
  282. "name": "VOLUME_CAPACITY",
  283. "displayName": "Volume Capacity",
  284. "description": "Volume space available for data, e.g. 512Mi, 2Gi.",
  285. "value": "1Gi",
  286. "required": true
  287. },
  288. {
  289. "name": "MONGODB_VERSION",
  290. "displayName": "Version of MongoDB Image",
  291. "description": "Version of MongoDB image to be used (2.4, 2.6, 3.2 or latest).",
  292. "value": "3.2",
  293. "required": true
  294. }
  295. ]
  296. }