nodejs-mongodb.json 15 KB

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