nodejs-mongodb-persistent.json 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "nodejs-mongo-persistent",
  6. "annotations": {
  7. "openshift.io/display-name": "Node.js + MongoDB (Persistent)",
  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. "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.",
  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-mongo-persistent"
  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-mongo-persistent"
  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-mongo-persistent",
  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": "PersistentVolumeClaim",
  264. "apiVersion": "v1",
  265. "metadata": {
  266. "name": "${DATABASE_SERVICE_NAME}"
  267. },
  268. "spec": {
  269. "accessModes": [
  270. "ReadWriteOnce"
  271. ],
  272. "resources": {
  273. "requests": {
  274. "storage": "${VOLUME_CAPACITY}"
  275. }
  276. }
  277. }
  278. },
  279. {
  280. "kind": "Service",
  281. "apiVersion": "v1",
  282. "metadata": {
  283. "name": "${DATABASE_SERVICE_NAME}",
  284. "annotations": {
  285. "description": "Exposes the database server"
  286. }
  287. },
  288. "spec": {
  289. "ports": [
  290. {
  291. "name": "mongodb",
  292. "port": 27017,
  293. "targetPort": 27017
  294. }
  295. ],
  296. "selector": {
  297. "name": "${DATABASE_SERVICE_NAME}"
  298. }
  299. }
  300. },
  301. {
  302. "kind": "DeploymentConfig",
  303. "apiVersion": "v1",
  304. "metadata": {
  305. "name": "${DATABASE_SERVICE_NAME}",
  306. "annotations": {
  307. "description": "Defines how to deploy the database"
  308. }
  309. },
  310. "spec": {
  311. "strategy": {
  312. "type": "Recreate"
  313. },
  314. "triggers": [
  315. {
  316. "type": "ImageChange",
  317. "imageChangeParams": {
  318. "automatic": true,
  319. "containerNames": [
  320. "mongodb"
  321. ],
  322. "from": {
  323. "kind": "ImageStreamTag",
  324. "namespace": "${NAMESPACE}",
  325. "name": "mongodb:3.2"
  326. }
  327. }
  328. },
  329. {
  330. "type": "ConfigChange"
  331. }
  332. ],
  333. "replicas": 1,
  334. "selector": {
  335. "name": "${DATABASE_SERVICE_NAME}"
  336. },
  337. "template": {
  338. "metadata": {
  339. "name": "${DATABASE_SERVICE_NAME}",
  340. "labels": {
  341. "name": "${DATABASE_SERVICE_NAME}"
  342. }
  343. },
  344. "spec": {
  345. "containers": [
  346. {
  347. "name": "mongodb",
  348. "image": " ",
  349. "ports": [
  350. {
  351. "containerPort": 27017
  352. }
  353. ],
  354. "env": [
  355. {
  356. "name": "MONGODB_USER",
  357. "valueFrom": {
  358. "secretKeyRef" : {
  359. "name" : "${NAME}",
  360. "key" : "database-user"
  361. }
  362. }
  363. },
  364. {
  365. "name": "MONGODB_PASSWORD",
  366. "valueFrom": {
  367. "secretKeyRef" : {
  368. "name" : "${NAME}",
  369. "key" : "database-password"
  370. }
  371. }
  372. },
  373. {
  374. "name": "MONGODB_DATABASE",
  375. "value": "${DATABASE_NAME}"
  376. },
  377. {
  378. "name": "MONGODB_ADMIN_PASSWORD",
  379. "valueFrom": {
  380. "secretKeyRef" : {
  381. "name" : "${NAME}",
  382. "key" : "database-admin-password"
  383. }
  384. }
  385. }
  386. ],
  387. "readinessProbe": {
  388. "timeoutSeconds": 1,
  389. "initialDelaySeconds": 3,
  390. "exec": {
  391. "command": [
  392. "/bin/sh",
  393. "-i",
  394. "-c",
  395. "mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p $MONGODB_PASSWORD --eval=\"quit()\""
  396. ]
  397. }
  398. },
  399. "livenessProbe": {
  400. "timeoutSeconds": 1,
  401. "initialDelaySeconds": 30,
  402. "tcpSocket": {
  403. "port": 27017
  404. }
  405. },
  406. "resources": {
  407. "limits": {
  408. "memory": "${MEMORY_MONGODB_LIMIT}"
  409. }
  410. },
  411. "volumeMounts": [
  412. {
  413. "name": "${DATABASE_SERVICE_NAME}-data",
  414. "mountPath": "/var/lib/mongodb/data"
  415. }
  416. ]
  417. }
  418. ],
  419. "volumes": [
  420. {
  421. "name": "${DATABASE_SERVICE_NAME}-data",
  422. "persistentVolumeClaim": {
  423. "claimName": "${DATABASE_SERVICE_NAME}"
  424. }
  425. }
  426. ]
  427. }
  428. }
  429. }
  430. }
  431. ],
  432. "parameters": [
  433. {
  434. "name": "NAME",
  435. "displayName": "Name",
  436. "description": "The name assigned to all of the frontend objects defined in this template.",
  437. "required": true,
  438. "value": "nodejs-mongo-persistent"
  439. },
  440. {
  441. "name": "NAMESPACE",
  442. "displayName": "Namespace",
  443. "description": "The OpenShift Namespace where the ImageStream resides.",
  444. "required": true,
  445. "value": "openshift"
  446. },
  447. {
  448. "name": "MEMORY_LIMIT",
  449. "displayName": "Memory Limit",
  450. "description": "Maximum amount of memory the Node.js container can use.",
  451. "required": true,
  452. "value": "512Mi"
  453. },
  454. {
  455. "name": "MEMORY_MONGODB_LIMIT",
  456. "displayName": "Memory Limit (MongoDB)",
  457. "description": "Maximum amount of memory the MongoDB container can use.",
  458. "required": true,
  459. "value": "512Mi"
  460. },
  461. {
  462. "name": "VOLUME_CAPACITY",
  463. "displayName": "Volume Capacity",
  464. "description": "Volume space available for data, e.g. 512Mi, 2Gi",
  465. "value": "1Gi",
  466. "required": true
  467. },
  468. {
  469. "name": "SOURCE_REPOSITORY_URL",
  470. "displayName": "Git Repository URL",
  471. "description": "The URL of the repository with your application source code.",
  472. "required": true,
  473. "value": "https://github.com/openshift/nodejs-ex.git"
  474. },
  475. {
  476. "name": "SOURCE_REPOSITORY_REF",
  477. "displayName": "Git Reference",
  478. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  479. },
  480. {
  481. "name": "CONTEXT_DIR",
  482. "displayName": "Context Directory",
  483. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  484. },
  485. {
  486. "name": "APPLICATION_DOMAIN",
  487. "displayName": "Application Hostname",
  488. "description": "The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.",
  489. "value": ""
  490. },
  491. {
  492. "name": "GITHUB_WEBHOOK_SECRET",
  493. "displayName": "GitHub Webhook Secret",
  494. "description": "A secret string used to configure the GitHub webhook.",
  495. "generate": "expression",
  496. "from": "[a-zA-Z0-9]{40}"
  497. },
  498. {
  499. "name": "GENERIC_WEBHOOK_SECRET",
  500. "displayName": "Generic Webhook Secret",
  501. "description": "A secret string used to configure the Generic webhook.",
  502. "generate": "expression",
  503. "from": "[a-zA-Z0-9]{40}"
  504. },
  505. {
  506. "name": "DATABASE_SERVICE_NAME",
  507. "displayName": "Database Service Name",
  508. "required": true,
  509. "value": "mongodb"
  510. },
  511. {
  512. "name": "DATABASE_USER",
  513. "displayName": "MongoDB Username",
  514. "description": "Username for MongoDB user that will be used for accessing the database.",
  515. "generate": "expression",
  516. "from": "user[A-Z0-9]{3}"
  517. },
  518. {
  519. "name": "DATABASE_PASSWORD",
  520. "displayName": "MongoDB Password",
  521. "description": "Password for the MongoDB user.",
  522. "generate": "expression",
  523. "from": "[a-zA-Z0-9]{16}"
  524. },
  525. {
  526. "name": "DATABASE_NAME",
  527. "displayName": "Database Name",
  528. "required": true,
  529. "value": "sampledb"
  530. },
  531. {
  532. "name": "DATABASE_ADMIN_PASSWORD",
  533. "displayName": "Database Administrator Password",
  534. "description": "Password for the database admin user.",
  535. "generate": "expression",
  536. "from": "[a-zA-Z0-9]{16}"
  537. },
  538. {
  539. "name": "NPM_MIRROR",
  540. "displayName": "Custom NPM Mirror URL",
  541. "description": "The custom NPM mirror URL",
  542. "value": ""
  543. }
  544. ]
  545. }