nodejs-mongodb-persistent.json 16 KB

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