nodejs-mongodb-persistent.json 16 KB

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