nodejs-mongodb.json 15 KB

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