nodejs-mongodb-persistent.json 15 KB

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