nodejs-mongodb.json 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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. }
  117. },
  118. {
  119. "kind": "DeploymentConfig",
  120. "apiVersion": "v1",
  121. "metadata": {
  122. "name": "${NAME}",
  123. "annotations": {
  124. "description": "Defines how to deploy the application server"
  125. }
  126. },
  127. "spec": {
  128. "strategy": {
  129. "type": "Rolling"
  130. },
  131. "triggers": [
  132. {
  133. "type": "ImageChange",
  134. "imageChangeParams": {
  135. "automatic": true,
  136. "containerNames": [
  137. "nodejs-mongodb-example"
  138. ],
  139. "from": {
  140. "kind": "ImageStreamTag",
  141. "name": "${NAME}:latest"
  142. }
  143. }
  144. },
  145. {
  146. "type": "ConfigChange"
  147. }
  148. ],
  149. "replicas": 1,
  150. "selector": {
  151. "name": "${NAME}"
  152. },
  153. "template": {
  154. "metadata": {
  155. "name": "${NAME}",
  156. "labels": {
  157. "name": "${NAME}"
  158. }
  159. },
  160. "spec": {
  161. "containers": [
  162. {
  163. "name": "nodejs-mongodb-example",
  164. "image": "nodejs-mongodb-example",
  165. "ports": [
  166. {
  167. "containerPort": 8080
  168. }
  169. ],
  170. "env": [
  171. {
  172. "name": "DATABASE_SERVICE_NAME",
  173. "value": "${DATABASE_SERVICE_NAME}"
  174. },
  175. {
  176. "name": "MONGODB_USER",
  177. "value": "${DATABASE_USER}"
  178. },
  179. {
  180. "name": "MONGODB_PASSWORD",
  181. "value": "${DATABASE_PASSWORD}"
  182. },
  183. {
  184. "name": "MONGODB_DATABASE",
  185. "value": "${DATABASE_NAME}"
  186. },
  187. {
  188. "name": "MONGODB_ADMIN_PASSWORD",
  189. "value": "${DATABASE_ADMIN_PASSWORD}"
  190. }
  191. ],
  192. "readinessProbe": {
  193. "timeoutSeconds": 3,
  194. "initialDelaySeconds": 3,
  195. "httpGet": {
  196. "path": "/pagecount",
  197. "port": 8080
  198. }
  199. },
  200. "livenessProbe": {
  201. "timeoutSeconds": 3,
  202. "initialDelaySeconds": 30,
  203. "httpGet": {
  204. "path": "/pagecount",
  205. "port": 8080
  206. }
  207. },
  208. "resources": {
  209. "limits": {
  210. "memory": "${MEMORY_LIMIT}"
  211. }
  212. }
  213. }
  214. ]
  215. }
  216. }
  217. }
  218. },
  219. {
  220. "kind": "Service",
  221. "apiVersion": "v1",
  222. "metadata": {
  223. "name": "${DATABASE_SERVICE_NAME}",
  224. "annotations": {
  225. "description": "Exposes the database server"
  226. }
  227. },
  228. "spec": {
  229. "ports": [
  230. {
  231. "name": "mongodb",
  232. "port": 27017,
  233. "targetPort": 27017
  234. }
  235. ],
  236. "selector": {
  237. "name": "${DATABASE_SERVICE_NAME}"
  238. }
  239. }
  240. },
  241. {
  242. "kind": "DeploymentConfig",
  243. "apiVersion": "v1",
  244. "metadata": {
  245. "name": "${DATABASE_SERVICE_NAME}",
  246. "annotations": {
  247. "description": "Defines how to deploy the database"
  248. }
  249. },
  250. "spec": {
  251. "strategy": {
  252. "type": "Recreate"
  253. },
  254. "triggers": [
  255. {
  256. "type": "ImageChange",
  257. "imageChangeParams": {
  258. "automatic": false,
  259. "containerNames": [
  260. "mongodb"
  261. ],
  262. "from": {
  263. "kind": "ImageStreamTag",
  264. "namespace": "${NAMESPACE}",
  265. "name": "mongodb:2.6"
  266. }
  267. }
  268. },
  269. {
  270. "type": "ConfigChange"
  271. }
  272. ],
  273. "replicas": 1,
  274. "selector": {
  275. "name": "${DATABASE_SERVICE_NAME}"
  276. },
  277. "template": {
  278. "metadata": {
  279. "name": "${DATABASE_SERVICE_NAME}",
  280. "labels": {
  281. "name": "${DATABASE_SERVICE_NAME}"
  282. }
  283. },
  284. "spec": {
  285. "containers": [
  286. {
  287. "name": "mongodb",
  288. "image": "mongodb",
  289. "ports": [
  290. {
  291. "containerPort": 27017
  292. }
  293. ],
  294. "env": [
  295. {
  296. "name": "MONGODB_USER",
  297. "value": "${DATABASE_USER}"
  298. },
  299. {
  300. "name": "MONGODB_PASSWORD",
  301. "value": "${DATABASE_PASSWORD}"
  302. },
  303. {
  304. "name": "MONGODB_DATABASE",
  305. "value": "${DATABASE_NAME}"
  306. },
  307. {
  308. "name": "MONGODB_ADMIN_PASSWORD",
  309. "value": "${DATABASE_ADMIN_PASSWORD}"
  310. }
  311. ],
  312. "readinessProbe": {
  313. "timeoutSeconds": 1,
  314. "initialDelaySeconds": 3,
  315. "exec": {
  316. "command": [ "/bin/sh", "-i", "-c", "mongostat --host 127.0.0.1 -u admin -p ${DATABASE_ADMIN_PASSWORD} -n 1 --noheaders"]
  317. }
  318. },
  319. "livenessProbe": {
  320. "timeoutSeconds": 1,
  321. "initialDelaySeconds": 30,
  322. "tcpSocket": {
  323. "port": 27017
  324. }
  325. },
  326. "resources": {
  327. "limits": {
  328. "memory": "${MEMORY_MONGODB_LIMIT}"
  329. }
  330. }
  331. }
  332. ]
  333. }
  334. }
  335. }
  336. }
  337. ],
  338. "parameters": [
  339. {
  340. "name": "NAME",
  341. "displayName": "Name",
  342. "description": "The name assigned to all of the frontend objects defined in this template.",
  343. "required": true,
  344. "value": "nodejs-mongodb-example"
  345. },
  346. {
  347. "name": "NAMESPACE",
  348. "displayName": "Namespace",
  349. "description": "The OpenShift Namespace where the ImageStream resides.",
  350. "value": "openshift"
  351. },
  352. {
  353. "name": "MEMORY_LIMIT",
  354. "displayName": "Memory Limit",
  355. "description": "Maximum amount of memory the Node.js container can use.",
  356. "value": "512Mi"
  357. },
  358. {
  359. "name": "MEMORY_MONGODB_LIMIT",
  360. "displayName": "Memory Limit (MongoDB)",
  361. "description": "Maximum amount of memory the MongoDB container can use.",
  362. "value": "512Mi"
  363. },
  364. {
  365. "name": "SOURCE_REPOSITORY_URL",
  366. "displayName": "Git Repository URL",
  367. "description": "The URL of the repository with your application source code.",
  368. "value": "https://github.com/openshift/nodejs-ex.git"
  369. },
  370. {
  371. "name": "SOURCE_REPOSITORY_REF",
  372. "displayName": "Git Reference",
  373. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  374. },
  375. {
  376. "name": "CONTEXT_DIR",
  377. "displayName": "Context Directory",
  378. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  379. },
  380. {
  381. "name": "APPLICATION_DOMAIN",
  382. "displayName": "Application Hostname",
  383. "description": "The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.",
  384. "value": ""
  385. },
  386. {
  387. "name": "GITHUB_WEBHOOK_SECRET",
  388. "displayName": "GitHub Webhook Secret",
  389. "description": "A secret string used to configure the GitHub webhook.",
  390. "generate": "expression",
  391. "from": "[a-zA-Z0-9]{40}"
  392. },
  393. {
  394. "name": "GENERIC_WEBHOOK_SECRET",
  395. "displayName": "Generic Webhook Secret",
  396. "description": "A secret string used to configure the Generic webhook.",
  397. "generate": "expression",
  398. "from": "[a-zA-Z0-9]{40}"
  399. },
  400. {
  401. "name": "DATABASE_SERVICE_NAME",
  402. "displayName": "Database Service Name",
  403. "value": "mongodb"
  404. },
  405. {
  406. "name": "DATABASE_USER",
  407. "displayName": "MongoDB Username",
  408. "description": "Username for MongoDB user that will be used for accessing the database.",
  409. "generate": "expression",
  410. "from": "user[A-Z0-9]{3}"
  411. },
  412. {
  413. "name": "DATABASE_PASSWORD",
  414. "displayName": "MongoDB Password",
  415. "description": "Password for the MongoDB user.",
  416. "generate": "expression",
  417. "from": "[a-zA-Z0-9]{16}"
  418. },
  419. {
  420. "name": "DATABASE_NAME",
  421. "displayName": "Database Name",
  422. "value": "sampledb"
  423. },
  424. {
  425. "name": "DATABASE_ADMIN_PASSWORD",
  426. "displayName": "Database Administrator Password",
  427. "description": "Password for the database admin user.",
  428. "generate": "expression",
  429. "from": "[a-zA-Z0-9]{16}"
  430. }
  431. ]
  432. }