nodejs-mongodb.json 15 KB

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