nodejs-mongodb.json 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "nodejs-mongodb-example",
  6. "annotations": {
  7. "description": "An example Node.js application with a MongoDB database",
  8. "tags": "quickstart,nodejs,mongodb",
  9. "iconClass": "icon-nodejs"
  10. }
  11. },
  12. "labels": {
  13. "template": "nodejs-mongodb-example"
  14. },
  15. "objects": [
  16. {
  17. "kind": "Service",
  18. "apiVersion": "v1",
  19. "metadata": {
  20. "name": "${NAME}",
  21. "annotations": {
  22. "description": "Exposes and load balances the application pods"
  23. }
  24. },
  25. "spec": {
  26. "ports": [
  27. {
  28. "name": "web",
  29. "port": 8080,
  30. "targetPort": 8080
  31. }
  32. ],
  33. "selector": {
  34. "name": "${NAME}"
  35. }
  36. }
  37. },
  38. {
  39. "kind": "Route",
  40. "apiVersion": "v1",
  41. "metadata": {
  42. "name": "${NAME}"
  43. },
  44. "spec": {
  45. "host": "${APPLICATION_DOMAIN}",
  46. "to": {
  47. "kind": "Service",
  48. "name": "${NAME}"
  49. }
  50. }
  51. },
  52. {
  53. "kind": "ImageStream",
  54. "apiVersion": "v1",
  55. "metadata": {
  56. "name": "${NAME}",
  57. "annotations": {
  58. "description": "Keeps track of changes in the application image"
  59. }
  60. }
  61. },
  62. {
  63. "kind": "BuildConfig",
  64. "apiVersion": "v1",
  65. "metadata": {
  66. "name": "${NAME}",
  67. "annotations": {
  68. "description": "Defines how to build the application"
  69. }
  70. },
  71. "spec": {
  72. "source": {
  73. "type": "Git",
  74. "git": {
  75. "uri": "${SOURCE_REPOSITORY_URL}",
  76. "ref": "${SOURCE_REPOSITORY_REF}"
  77. },
  78. "contextDir": "${CONTEXT_DIR}"
  79. },
  80. "strategy": {
  81. "type": "Source",
  82. "sourceStrategy": {
  83. "from": {
  84. "kind": "ImageStreamTag",
  85. "namespace": "${NAMESPACE}",
  86. "name": "nodejs:0.10"
  87. }
  88. }
  89. },
  90. "output": {
  91. "to": {
  92. "kind": "ImageStreamTag",
  93. "name": "${NAME}:latest"
  94. }
  95. },
  96. "triggers": [
  97. {
  98. "type": "ImageChange"
  99. },
  100. {
  101. "type": "ConfigChange"
  102. },
  103. {
  104. "type": "GitHub",
  105. "github": {
  106. "secret": "${GITHUB_WEBHOOK_SECRET}"
  107. }
  108. },
  109. {
  110. "type": "Generic",
  111. "generic": {
  112. "secret": "${GENERIC_WEBHOOK_SECRET}"
  113. }
  114. }
  115. ],
  116. "postCommit": {
  117. "script": "npm test"
  118. }
  119. }
  120. },
  121. {
  122. "kind": "DeploymentConfig",
  123. "apiVersion": "v1",
  124. "metadata": {
  125. "name": "${NAME}",
  126. "annotations": {
  127. "description": "Defines how to deploy the application server"
  128. }
  129. },
  130. "spec": {
  131. "strategy": {
  132. "type": "Rolling"
  133. },
  134. "triggers": [
  135. {
  136. "type": "ImageChange",
  137. "imageChangeParams": {
  138. "automatic": true,
  139. "containerNames": [
  140. "nodejs-mongodb-example"
  141. ],
  142. "from": {
  143. "kind": "ImageStreamTag",
  144. "name": "${NAME}:latest"
  145. }
  146. }
  147. },
  148. {
  149. "type": "ConfigChange"
  150. }
  151. ],
  152. "replicas": 1,
  153. "selector": {
  154. "name": "${NAME}"
  155. },
  156. "template": {
  157. "metadata": {
  158. "name": "${NAME}",
  159. "labels": {
  160. "name": "${NAME}"
  161. }
  162. },
  163. "spec": {
  164. "containers": [
  165. {
  166. "name": "nodejs-mongodb-example",
  167. "image": " ",
  168. "ports": [
  169. {
  170. "containerPort": 8080
  171. }
  172. ],
  173. "env": [
  174. {
  175. "name": "DATABASE_SERVICE_NAME",
  176. "value": "${DATABASE_SERVICE_NAME}"
  177. },
  178. {
  179. "name": "MONGODB_USER",
  180. "value": "${DATABASE_USER}"
  181. },
  182. {
  183. "name": "MONGODB_PASSWORD",
  184. "value": "${DATABASE_PASSWORD}"
  185. },
  186. {
  187. "name": "MONGODB_DATABASE",
  188. "value": "${DATABASE_NAME}"
  189. },
  190. {
  191. "name": "MONGODB_ADMIN_PASSWORD",
  192. "value": "${DATABASE_ADMIN_PASSWORD}"
  193. }
  194. ],
  195. "readinessProbe": {
  196. "timeoutSeconds": 3,
  197. "initialDelaySeconds": 3,
  198. "httpGet": {
  199. "path": "/pagecount",
  200. "port": 8080
  201. }
  202. },
  203. "livenessProbe": {
  204. "timeoutSeconds": 3,
  205. "initialDelaySeconds": 30,
  206. "httpGet": {
  207. "path": "/pagecount",
  208. "port": 8080
  209. }
  210. },
  211. "resources": {
  212. "limits": {
  213. "memory": "${MEMORY_LIMIT}"
  214. }
  215. }
  216. }
  217. ]
  218. }
  219. }
  220. }
  221. },
  222. {
  223. "kind": "Service",
  224. "apiVersion": "v1",
  225. "metadata": {
  226. "name": "${DATABASE_SERVICE_NAME}",
  227. "annotations": {
  228. "description": "Exposes the database server"
  229. }
  230. },
  231. "spec": {
  232. "ports": [
  233. {
  234. "name": "mongodb",
  235. "port": 27017,
  236. "targetPort": 27017
  237. }
  238. ],
  239. "selector": {
  240. "name": "${DATABASE_SERVICE_NAME}"
  241. }
  242. }
  243. },
  244. {
  245. "kind": "DeploymentConfig",
  246. "apiVersion": "v1",
  247. "metadata": {
  248. "name": "${DATABASE_SERVICE_NAME}",
  249. "annotations": {
  250. "description": "Defines how to deploy the database"
  251. }
  252. },
  253. "spec": {
  254. "strategy": {
  255. "type": "Recreate"
  256. },
  257. "triggers": [
  258. {
  259. "type": "ImageChange",
  260. "imageChangeParams": {
  261. "automatic": true,
  262. "containerNames": [
  263. "mongodb"
  264. ],
  265. "from": {
  266. "kind": "ImageStreamTag",
  267. "namespace": "${NAMESPACE}",
  268. "name": "mongodb:2.6"
  269. }
  270. }
  271. },
  272. {
  273. "type": "ConfigChange"
  274. }
  275. ],
  276. "replicas": 1,
  277. "selector": {
  278. "name": "${DATABASE_SERVICE_NAME}"
  279. },
  280. "template": {
  281. "metadata": {
  282. "name": "${DATABASE_SERVICE_NAME}",
  283. "labels": {
  284. "name": "${DATABASE_SERVICE_NAME}"
  285. }
  286. },
  287. "spec": {
  288. "containers": [
  289. {
  290. "name": "mongodb",
  291. "image": " ",
  292. "ports": [
  293. {
  294. "containerPort": 27017
  295. }
  296. ],
  297. "env": [
  298. {
  299. "name": "MONGODB_USER",
  300. "value": "${DATABASE_USER}"
  301. },
  302. {
  303. "name": "MONGODB_PASSWORD",
  304. "value": "${DATABASE_PASSWORD}"
  305. },
  306. {
  307. "name": "MONGODB_DATABASE",
  308. "value": "${DATABASE_NAME}"
  309. },
  310. {
  311. "name": "MONGODB_ADMIN_PASSWORD",
  312. "value": "${DATABASE_ADMIN_PASSWORD}"
  313. }
  314. ],
  315. "readinessProbe": {
  316. "timeoutSeconds": 1,
  317. "initialDelaySeconds": 3,
  318. "exec": {
  319. "command": [ "/bin/sh", "-i", "-c", "mongostat --host 127.0.0.1 -u admin -p ${DATABASE_ADMIN_PASSWORD} -n 1 --noheaders"]
  320. }
  321. },
  322. "livenessProbe": {
  323. "timeoutSeconds": 1,
  324. "initialDelaySeconds": 30,
  325. "tcpSocket": {
  326. "port": 27017
  327. }
  328. },
  329. "resources": {
  330. "limits": {
  331. "memory": "${MEMORY_MONGODB_LIMIT}"
  332. }
  333. },
  334. "volumeMounts": [
  335. {
  336. "name": "${DATABASE_SERVICE_NAME}-data",
  337. "mountPath": "/var/lib/mongodb/data"
  338. }
  339. ]
  340. }
  341. ],
  342. "volumes": [
  343. {
  344. "name": "${DATABASE_SERVICE_NAME}-data",
  345. "emptyDir": {
  346. "medium": ""
  347. }
  348. }
  349. ]
  350. }
  351. }
  352. }
  353. }
  354. ],
  355. "parameters": [
  356. {
  357. "name": "NAME",
  358. "displayName": "Name",
  359. "description": "The name assigned to all of the frontend objects defined in this template.",
  360. "required": true,
  361. "value": "nodejs-mongodb-example"
  362. },
  363. {
  364. "name": "NAMESPACE",
  365. "displayName": "Namespace",
  366. "description": "The OpenShift Namespace where the ImageStream resides.",
  367. "value": "openshift"
  368. },
  369. {
  370. "name": "MEMORY_LIMIT",
  371. "displayName": "Memory Limit",
  372. "description": "Maximum amount of memory the Node.js container can use.",
  373. "value": "512Mi"
  374. },
  375. {
  376. "name": "MEMORY_MONGODB_LIMIT",
  377. "displayName": "Memory Limit (MongoDB)",
  378. "description": "Maximum amount of memory the MongoDB container can use.",
  379. "value": "512Mi"
  380. },
  381. {
  382. "name": "SOURCE_REPOSITORY_URL",
  383. "displayName": "Git Repository URL",
  384. "description": "The URL of the repository with your application source code.",
  385. "value": "https://github.com/openshift/nodejs-ex.git"
  386. },
  387. {
  388. "name": "SOURCE_REPOSITORY_REF",
  389. "displayName": "Git Reference",
  390. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  391. },
  392. {
  393. "name": "CONTEXT_DIR",
  394. "displayName": "Context Directory",
  395. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  396. },
  397. {
  398. "name": "APPLICATION_DOMAIN",
  399. "displayName": "Application Hostname",
  400. "description": "The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.",
  401. "value": ""
  402. },
  403. {
  404. "name": "GITHUB_WEBHOOK_SECRET",
  405. "displayName": "GitHub Webhook Secret",
  406. "description": "A secret string used to configure the GitHub webhook.",
  407. "generate": "expression",
  408. "from": "[a-zA-Z0-9]{40}"
  409. },
  410. {
  411. "name": "GENERIC_WEBHOOK_SECRET",
  412. "displayName": "Generic Webhook Secret",
  413. "description": "A secret string used to configure the Generic webhook.",
  414. "generate": "expression",
  415. "from": "[a-zA-Z0-9]{40}"
  416. },
  417. {
  418. "name": "DATABASE_SERVICE_NAME",
  419. "displayName": "Database Service Name",
  420. "value": "mongodb"
  421. },
  422. {
  423. "name": "DATABASE_USER",
  424. "displayName": "MongoDB Username",
  425. "description": "Username for MongoDB user that will be used for accessing the database.",
  426. "generate": "expression",
  427. "from": "user[A-Z0-9]{3}"
  428. },
  429. {
  430. "name": "DATABASE_PASSWORD",
  431. "displayName": "MongoDB Password",
  432. "description": "Password for the MongoDB user.",
  433. "generate": "expression",
  434. "from": "[a-zA-Z0-9]{16}"
  435. },
  436. {
  437. "name": "DATABASE_NAME",
  438. "displayName": "Database Name",
  439. "value": "sampledb"
  440. },
  441. {
  442. "name": "DATABASE_ADMIN_PASSWORD",
  443. "displayName": "Database Administrator Password",
  444. "description": "Password for the database admin user.",
  445. "generate": "expression",
  446. "from": "[a-zA-Z0-9]{16}"
  447. }
  448. ]
  449. }