nodejs-mongodb.json 15 KB

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