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 (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. "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-mongo-persistent"
  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-mongo-persistent",
  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": "PersistentVolumeClaim",
  269. "apiVersion": "v1",
  270. "metadata": {
  271. "name": "${DATABASE_SERVICE_NAME}"
  272. },
  273. "spec": {
  274. "accessModes": [
  275. "ReadWriteOnce"
  276. ],
  277. "resources": {
  278. "requests": {
  279. "storage": "${VOLUME_CAPACITY}"
  280. }
  281. }
  282. }
  283. },
  284. {
  285. "kind": "Service",
  286. "apiVersion": "v1",
  287. "metadata": {
  288. "name": "${DATABASE_SERVICE_NAME}",
  289. "annotations": {
  290. "description": "Exposes the database server"
  291. }
  292. },
  293. "spec": {
  294. "ports": [
  295. {
  296. "name": "mongodb",
  297. "port": 27017,
  298. "targetPort": 27017
  299. }
  300. ],
  301. "selector": {
  302. "name": "${DATABASE_SERVICE_NAME}"
  303. }
  304. }
  305. },
  306. {
  307. "kind": "DeploymentConfig",
  308. "apiVersion": "v1",
  309. "metadata": {
  310. "name": "${DATABASE_SERVICE_NAME}",
  311. "annotations": {
  312. "description": "Defines how to deploy the database"
  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. }