nodejs-mongodb.json 13 KB

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