nodejs-mongodb-persistent.json 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  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. }
  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. }
  157. },
  158. "spec": {
  159. "strategy": {
  160. "type": "Recreate"
  161. },
  162. "triggers": [
  163. {
  164. "type": "ImageChange",
  165. "imageChangeParams": {
  166. "automatic": true,
  167. "containerNames": [
  168. "nodejs-mongo-persistent"
  169. ],
  170. "from": {
  171. "kind": "ImageStreamTag",
  172. "name": "${NAME}:latest"
  173. }
  174. }
  175. },
  176. {
  177. "type": "ConfigChange"
  178. }
  179. ],
  180. "replicas": 1,
  181. "selector": {
  182. "name": "${NAME}"
  183. },
  184. "template": {
  185. "metadata": {
  186. "name": "${NAME}",
  187. "labels": {
  188. "name": "${NAME}"
  189. }
  190. },
  191. "spec": {
  192. "containers": [
  193. {
  194. "name": "nodejs-mongo-persistent",
  195. "image": " ",
  196. "ports": [
  197. {
  198. "containerPort": 8080
  199. }
  200. ],
  201. "env": [
  202. {
  203. "name": "DATABASE_SERVICE_NAME",
  204. "value": "${DATABASE_SERVICE_NAME}"
  205. },
  206. {
  207. "name": "MONGODB_USER",
  208. "valueFrom": {
  209. "secretKeyRef" : {
  210. "name" : "${NAME}",
  211. "key" : "database-user"
  212. }
  213. }
  214. },
  215. {
  216. "name": "MONGODB_PASSWORD",
  217. "valueFrom": {
  218. "secretKeyRef" : {
  219. "name" : "${NAME}",
  220. "key" : "database-password"
  221. }
  222. }
  223. },
  224. {
  225. "name": "MONGODB_DATABASE",
  226. "value": "${DATABASE_NAME}"
  227. },
  228. {
  229. "name": "MONGODB_ADMIN_PASSWORD",
  230. "valueFrom": {
  231. "secretKeyRef" : {
  232. "name" : "${NAME}",
  233. "key" : "database-admin-password"
  234. }
  235. }
  236. }
  237. ],
  238. "readinessProbe": {
  239. "timeoutSeconds": 3,
  240. "initialDelaySeconds": 3,
  241. "httpGet": {
  242. "path": "/pagecount",
  243. "port": 8080
  244. }
  245. },
  246. "livenessProbe": {
  247. "timeoutSeconds": 3,
  248. "initialDelaySeconds": 30,
  249. "httpGet": {
  250. "path": "/pagecount",
  251. "port": 8080
  252. }
  253. },
  254. "resources": {
  255. "limits": {
  256. "memory": "${MEMORY_LIMIT}"
  257. }
  258. }
  259. }
  260. ]
  261. }
  262. }
  263. }
  264. },
  265. {
  266. "kind": "PersistentVolumeClaim",
  267. "apiVersion": "v1",
  268. "metadata": {
  269. "name": "${DATABASE_SERVICE_NAME}"
  270. },
  271. "spec": {
  272. "accessModes": [
  273. "ReadWriteOnce"
  274. ],
  275. "resources": {
  276. "requests": {
  277. "storage": "${VOLUME_CAPACITY}"
  278. }
  279. }
  280. }
  281. },
  282. {
  283. "kind": "Service",
  284. "apiVersion": "v1",
  285. "metadata": {
  286. "name": "${DATABASE_SERVICE_NAME}",
  287. "annotations": {
  288. "description": "Exposes the database server"
  289. }
  290. },
  291. "spec": {
  292. "ports": [
  293. {
  294. "name": "mongodb",
  295. "port": 27017,
  296. "targetPort": 27017
  297. }
  298. ],
  299. "selector": {
  300. "name": "${DATABASE_SERVICE_NAME}"
  301. }
  302. }
  303. },
  304. {
  305. "kind": "DeploymentConfig",
  306. "apiVersion": "v1",
  307. "metadata": {
  308. "name": "${DATABASE_SERVICE_NAME}",
  309. "annotations": {
  310. "description": "Defines how to deploy the database"
  311. }
  312. },
  313. "spec": {
  314. "strategy": {
  315. "type": "Recreate"
  316. },
  317. "triggers": [
  318. {
  319. "type": "ImageChange",
  320. "imageChangeParams": {
  321. "automatic": true,
  322. "containerNames": [
  323. "mongodb"
  324. ],
  325. "from": {
  326. "kind": "ImageStreamTag",
  327. "namespace": "${NAMESPACE}",
  328. "name": "mongodb:3.2"
  329. }
  330. }
  331. },
  332. {
  333. "type": "ConfigChange"
  334. }
  335. ],
  336. "replicas": 1,
  337. "selector": {
  338. "name": "${DATABASE_SERVICE_NAME}"
  339. },
  340. "template": {
  341. "metadata": {
  342. "name": "${DATABASE_SERVICE_NAME}",
  343. "labels": {
  344. "name": "${DATABASE_SERVICE_NAME}"
  345. }
  346. },
  347. "spec": {
  348. "containers": [
  349. {
  350. "name": "mongodb",
  351. "image": " ",
  352. "ports": [
  353. {
  354. "containerPort": 27017
  355. }
  356. ],
  357. "env": [
  358. {
  359. "name": "MONGODB_USER",
  360. "valueFrom": {
  361. "secretKeyRef" : {
  362. "name" : "${NAME}",
  363. "key" : "database-user"
  364. }
  365. }
  366. },
  367. {
  368. "name": "MONGODB_PASSWORD",
  369. "valueFrom": {
  370. "secretKeyRef" : {
  371. "name" : "${NAME}",
  372. "key" : "database-password"
  373. }
  374. }
  375. },
  376. {
  377. "name": "MONGODB_DATABASE",
  378. "value": "${DATABASE_NAME}"
  379. },
  380. {
  381. "name": "MONGODB_ADMIN_PASSWORD",
  382. "valueFrom": {
  383. "secretKeyRef" : {
  384. "name" : "${NAME}",
  385. "key" : "database-admin-password"
  386. }
  387. }
  388. }
  389. ],
  390. "readinessProbe": {
  391. "timeoutSeconds": 1,
  392. "initialDelaySeconds": 3,
  393. "exec": {
  394. "command": [
  395. "/bin/sh",
  396. "-i",
  397. "-c",
  398. "mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p $MONGODB_PASSWORD --eval=\"quit()\""
  399. ]
  400. }
  401. },
  402. "livenessProbe": {
  403. "timeoutSeconds": 1,
  404. "initialDelaySeconds": 30,
  405. "tcpSocket": {
  406. "port": 27017
  407. }
  408. },
  409. "resources": {
  410. "limits": {
  411. "memory": "${MEMORY_MONGODB_LIMIT}"
  412. }
  413. },
  414. "volumeMounts": [
  415. {
  416. "name": "${DATABASE_SERVICE_NAME}-data",
  417. "mountPath": "/var/lib/mongodb/data"
  418. }
  419. ]
  420. }
  421. ],
  422. "volumes": [
  423. {
  424. "name": "${DATABASE_SERVICE_NAME}-data",
  425. "persistentVolumeClaim": {
  426. "claimName": "${DATABASE_SERVICE_NAME}"
  427. }
  428. }
  429. ]
  430. }
  431. }
  432. }
  433. }
  434. ],
  435. "parameters": [
  436. {
  437. "name": "NAME",
  438. "displayName": "Name",
  439. "description": "The name assigned to all of the frontend objects defined in this template.",
  440. "required": true,
  441. "value": "nodejs-mongo-persistent"
  442. },
  443. {
  444. "name": "NAMESPACE",
  445. "displayName": "Namespace",
  446. "description": "The OpenShift Namespace where the ImageStream resides.",
  447. "required": true,
  448. "value": "openshift"
  449. },
  450. {
  451. "name": "MEMORY_LIMIT",
  452. "displayName": "Memory Limit",
  453. "description": "Maximum amount of memory the Node.js container can use.",
  454. "required": true,
  455. "value": "512Mi"
  456. },
  457. {
  458. "name": "MEMORY_MONGODB_LIMIT",
  459. "displayName": "Memory Limit (MongoDB)",
  460. "description": "Maximum amount of memory the MongoDB container can use.",
  461. "required": true,
  462. "value": "512Mi"
  463. },
  464. {
  465. "name": "VOLUME_CAPACITY",
  466. "displayName": "Volume Capacity",
  467. "description": "Volume space available for data, e.g. 512Mi, 2Gi",
  468. "value": "1Gi",
  469. "required": true
  470. },
  471. {
  472. "name": "SOURCE_REPOSITORY_URL",
  473. "displayName": "Git Repository URL",
  474. "description": "The URL of the repository with your application source code.",
  475. "required": true,
  476. "value": "https://github.com/openshift/nodejs-ex.git"
  477. },
  478. {
  479. "name": "SOURCE_REPOSITORY_REF",
  480. "displayName": "Git Reference",
  481. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  482. },
  483. {
  484. "name": "CONTEXT_DIR",
  485. "displayName": "Context Directory",
  486. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  487. },
  488. {
  489. "name": "APPLICATION_DOMAIN",
  490. "displayName": "Application Hostname",
  491. "description": "The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.",
  492. "value": ""
  493. },
  494. {
  495. "name": "GITHUB_WEBHOOK_SECRET",
  496. "displayName": "GitHub Webhook Secret",
  497. "description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.",
  498. "generate": "expression",
  499. "from": "[a-zA-Z0-9]{40}"
  500. },
  501. {
  502. "name": "GENERIC_WEBHOOK_SECRET",
  503. "displayName": "Generic Webhook Secret",
  504. "description": "A secret string used to configure the Generic webhook.",
  505. "generate": "expression",
  506. "from": "[a-zA-Z0-9]{40}"
  507. },
  508. {
  509. "name": "DATABASE_SERVICE_NAME",
  510. "displayName": "Database Service Name",
  511. "required": true,
  512. "value": "mongodb"
  513. },
  514. {
  515. "name": "DATABASE_USER",
  516. "displayName": "MongoDB Username",
  517. "description": "Username for MongoDB user that will be used for accessing the database.",
  518. "generate": "expression",
  519. "from": "user[A-Z0-9]{3}"
  520. },
  521. {
  522. "name": "DATABASE_PASSWORD",
  523. "displayName": "MongoDB Password",
  524. "description": "Password for the MongoDB user.",
  525. "generate": "expression",
  526. "from": "[a-zA-Z0-9]{16}"
  527. },
  528. {
  529. "name": "DATABASE_NAME",
  530. "displayName": "Database Name",
  531. "required": true,
  532. "value": "sampledb"
  533. },
  534. {
  535. "name": "DATABASE_ADMIN_PASSWORD",
  536. "displayName": "Database Administrator Password",
  537. "description": "Password for the database admin user.",
  538. "generate": "expression",
  539. "from": "[a-zA-Z0-9]{16}"
  540. },
  541. {
  542. "name": "NPM_MIRROR",
  543. "displayName": "Custom NPM Mirror URL",
  544. "description": "The custom NPM mirror URL",
  545. "value": ""
  546. }
  547. ]
  548. }