nodejs-mongodb.json 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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. }
  12. },
  13. "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.",
  14. "labels": {
  15. "template": "nodejs-mongodb-example"
  16. },
  17. "objects": [
  18. {
  19. "kind": "Secret",
  20. "apiVersion": "v1",
  21. "metadata": {
  22. "name": "${NAME}"
  23. },
  24. "stringData": {
  25. "databaseUser": "${DATABASE_USER}",
  26. "databasePassword": "${DATABASE_PASSWORD}",
  27. "databaseAdminPassword" : "${DATABASE_ADMIN_PASSWORD}"
  28. }
  29. },
  30. {
  31. "kind": "Service",
  32. "apiVersion": "v1",
  33. "metadata": {
  34. "name": "${NAME}",
  35. "annotations": {
  36. "description": "Exposes and load balances the application pods",
  37. "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]"
  38. }
  39. },
  40. "spec": {
  41. "ports": [
  42. {
  43. "name": "web",
  44. "port": 8080,
  45. "targetPort": 8080
  46. }
  47. ],
  48. "selector": {
  49. "name": "${NAME}"
  50. }
  51. }
  52. },
  53. {
  54. "kind": "Route",
  55. "apiVersion": "v1",
  56. "metadata": {
  57. "name": "${NAME}"
  58. },
  59. "spec": {
  60. "host": "${APPLICATION_DOMAIN}",
  61. "to": {
  62. "kind": "Service",
  63. "name": "${NAME}"
  64. }
  65. }
  66. },
  67. {
  68. "kind": "ImageStream",
  69. "apiVersion": "v1",
  70. "metadata": {
  71. "name": "${NAME}",
  72. "annotations": {
  73. "description": "Keeps track of changes in the application image"
  74. }
  75. }
  76. },
  77. {
  78. "kind": "BuildConfig",
  79. "apiVersion": "v1",
  80. "metadata": {
  81. "name": "${NAME}",
  82. "annotations": {
  83. "description": "Defines how to build the application"
  84. }
  85. },
  86. "spec": {
  87. "source": {
  88. "type": "Git",
  89. "git": {
  90. "uri": "${SOURCE_REPOSITORY_URL}",
  91. "ref": "${SOURCE_REPOSITORY_REF}"
  92. },
  93. "contextDir": "${CONTEXT_DIR}"
  94. },
  95. "strategy": {
  96. "type": "Source",
  97. "sourceStrategy": {
  98. "from": {
  99. "kind": "ImageStreamTag",
  100. "namespace": "${NAMESPACE}",
  101. "name": "nodejs:4"
  102. },
  103. "env": [
  104. {
  105. "name": "NPM_MIRROR",
  106. "value": "${NPM_MIRROR}"
  107. }
  108. ]
  109. }
  110. },
  111. "output": {
  112. "to": {
  113. "kind": "ImageStreamTag",
  114. "name": "${NAME}:latest"
  115. }
  116. },
  117. "triggers": [
  118. {
  119. "type": "ImageChange"
  120. },
  121. {
  122. "type": "ConfigChange"
  123. },
  124. {
  125. "type": "GitHub",
  126. "github": {
  127. "secret": "${GITHUB_WEBHOOK_SECRET}"
  128. }
  129. },
  130. {
  131. "type": "Generic",
  132. "generic": {
  133. "secret": "${GENERIC_WEBHOOK_SECRET}"
  134. }
  135. }
  136. ],
  137. "postCommit": {
  138. "script": "npm test"
  139. }
  140. }
  141. },
  142. {
  143. "kind": "DeploymentConfig",
  144. "apiVersion": "v1",
  145. "metadata": {
  146. "name": "${NAME}",
  147. "annotations": {
  148. "description": "Defines how to deploy the application server"
  149. }
  150. },
  151. "spec": {
  152. "strategy": {
  153. "type": "Rolling"
  154. },
  155. "triggers": [
  156. {
  157. "type": "ImageChange",
  158. "imageChangeParams": {
  159. "automatic": true,
  160. "containerNames": [
  161. "nodejs-mongodb-example"
  162. ],
  163. "from": {
  164. "kind": "ImageStreamTag",
  165. "name": "${NAME}:latest"
  166. }
  167. }
  168. },
  169. {
  170. "type": "ConfigChange"
  171. }
  172. ],
  173. "replicas": 1,
  174. "selector": {
  175. "name": "${NAME}"
  176. },
  177. "template": {
  178. "metadata": {
  179. "name": "${NAME}",
  180. "labels": {
  181. "name": "${NAME}"
  182. }
  183. },
  184. "spec": {
  185. "containers": [
  186. {
  187. "name": "nodejs-mongodb-example",
  188. "image": " ",
  189. "ports": [
  190. {
  191. "containerPort": 8080
  192. }
  193. ],
  194. "env": [
  195. {
  196. "name": "DATABASE_SERVICE_NAME",
  197. "value": "${DATABASE_SERVICE_NAME}"
  198. },
  199. {
  200. "name": "MONGODB_USER",
  201. "valueFrom": {
  202. "secretKeyRef" : {
  203. "name" : "${NAME}",
  204. "key" : "databaseUser"
  205. }
  206. }
  207. },
  208. {
  209. "name": "MONGODB_PASSWORD",
  210. "valueFrom": {
  211. "secretKeyRef" : {
  212. "name" : "${NAME}",
  213. "key" : "databasePassword"
  214. }
  215. }
  216. },
  217. {
  218. "name": "MONGODB_DATABASE",
  219. "value": "${DATABASE_NAME}"
  220. },
  221. {
  222. "name": "MONGODB_ADMIN_PASSWORD",
  223. "valueFrom": {
  224. "secretKeyRef" : {
  225. "name" : "${NAME}",
  226. "key" : "databaseAdminPassword"
  227. }
  228. }
  229. }
  230. ],
  231. "readinessProbe": {
  232. "timeoutSeconds": 3,
  233. "initialDelaySeconds": 3,
  234. "httpGet": {
  235. "path": "/pagecount",
  236. "port": 8080
  237. }
  238. },
  239. "livenessProbe": {
  240. "timeoutSeconds": 3,
  241. "initialDelaySeconds": 30,
  242. "httpGet": {
  243. "path": "/pagecount",
  244. "port": 8080
  245. }
  246. },
  247. "resources": {
  248. "limits": {
  249. "memory": "${MEMORY_LIMIT}"
  250. }
  251. }
  252. }
  253. ]
  254. }
  255. }
  256. }
  257. },
  258. {
  259. "kind": "Service",
  260. "apiVersion": "v1",
  261. "metadata": {
  262. "name": "${DATABASE_SERVICE_NAME}",
  263. "annotations": {
  264. "description": "Exposes the database server"
  265. }
  266. },
  267. "spec": {
  268. "ports": [
  269. {
  270. "name": "mongodb",
  271. "port": 27017,
  272. "targetPort": 27017
  273. }
  274. ],
  275. "selector": {
  276. "name": "${DATABASE_SERVICE_NAME}"
  277. }
  278. }
  279. },
  280. {
  281. "kind": "DeploymentConfig",
  282. "apiVersion": "v1",
  283. "metadata": {
  284. "name": "${DATABASE_SERVICE_NAME}",
  285. "annotations": {
  286. "description": "Defines how to deploy the database"
  287. }
  288. },
  289. "spec": {
  290. "strategy": {
  291. "type": "Recreate"
  292. },
  293. "triggers": [
  294. {
  295. "type": "ImageChange",
  296. "imageChangeParams": {
  297. "automatic": true,
  298. "containerNames": [
  299. "mongodb"
  300. ],
  301. "from": {
  302. "kind": "ImageStreamTag",
  303. "namespace": "${NAMESPACE}",
  304. "name": "mongodb:3.2"
  305. }
  306. }
  307. },
  308. {
  309. "type": "ConfigChange"
  310. }
  311. ],
  312. "replicas": 1,
  313. "selector": {
  314. "name": "${DATABASE_SERVICE_NAME}"
  315. },
  316. "template": {
  317. "metadata": {
  318. "name": "${DATABASE_SERVICE_NAME}",
  319. "labels": {
  320. "name": "${DATABASE_SERVICE_NAME}"
  321. }
  322. },
  323. "spec": {
  324. "containers": [
  325. {
  326. "name": "mongodb",
  327. "image": " ",
  328. "ports": [
  329. {
  330. "containerPort": 27017
  331. }
  332. ],
  333. "env": [
  334. {
  335. "name": "MONGODB_USER",
  336. "valueFrom": {
  337. "secretKeyRef" : {
  338. "name" : "${NAME}",
  339. "key" : "databaseUser"
  340. }
  341. }
  342. },
  343. {
  344. "name": "MONGODB_PASSWORD",
  345. "valueFrom": {
  346. "secretKeyRef" : {
  347. "name" : "${NAME}",
  348. "key" : "databasePassword"
  349. }
  350. }
  351. },
  352. {
  353. "name": "MONGODB_DATABASE",
  354. "value": "${DATABASE_NAME}"
  355. },
  356. {
  357. "name": "MONGODB_ADMIN_PASSWORD",
  358. "valueFrom": {
  359. "secretKeyRef" : {
  360. "name" : "${NAME}",
  361. "key" : "databaseAdminPassword"
  362. }
  363. }
  364. }
  365. ],
  366. "readinessProbe": {
  367. "timeoutSeconds": 1,
  368. "initialDelaySeconds": 3,
  369. "exec": {
  370. "command": [
  371. "/bin/sh",
  372. "-i",
  373. "-c",
  374. "mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p $MONGODB_PASSWORD --eval=\"quit()\""
  375. ]
  376. }
  377. },
  378. "livenessProbe": {
  379. "timeoutSeconds": 1,
  380. "initialDelaySeconds": 30,
  381. "tcpSocket": {
  382. "port": 27017
  383. }
  384. },
  385. "resources": {
  386. "limits": {
  387. "memory": "${MEMORY_MONGODB_LIMIT}"
  388. }
  389. },
  390. "volumeMounts": [
  391. {
  392. "name": "${DATABASE_SERVICE_NAME}-data",
  393. "mountPath": "/var/lib/mongodb/data"
  394. }
  395. ]
  396. }
  397. ],
  398. "volumes": [
  399. {
  400. "name": "${DATABASE_SERVICE_NAME}-data",
  401. "emptyDir": {
  402. "medium": ""
  403. }
  404. }
  405. ]
  406. }
  407. }
  408. }
  409. }
  410. ],
  411. "parameters": [
  412. {
  413. "name": "NAME",
  414. "displayName": "Name",
  415. "description": "The name assigned to all of the frontend objects defined in this template.",
  416. "required": true,
  417. "value": "nodejs-mongodb-example"
  418. },
  419. {
  420. "name": "NAMESPACE",
  421. "displayName": "Namespace",
  422. "description": "The OpenShift Namespace where the ImageStream resides.",
  423. "required": true,
  424. "value": "openshift"
  425. },
  426. {
  427. "name": "MEMORY_LIMIT",
  428. "displayName": "Memory Limit",
  429. "description": "Maximum amount of memory the Node.js container can use.",
  430. "required": true,
  431. "value": "512Mi"
  432. },
  433. {
  434. "name": "MEMORY_MONGODB_LIMIT",
  435. "displayName": "Memory Limit (MongoDB)",
  436. "description": "Maximum amount of memory the MongoDB container can use.",
  437. "required": true,
  438. "value": "512Mi"
  439. },
  440. {
  441. "name": "SOURCE_REPOSITORY_URL",
  442. "displayName": "Git Repository URL",
  443. "description": "The URL of the repository with your application source code.",
  444. "required": true,
  445. "value": "https://github.com/openshift/nodejs-ex.git"
  446. },
  447. {
  448. "name": "SOURCE_REPOSITORY_REF",
  449. "displayName": "Git Reference",
  450. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  451. },
  452. {
  453. "name": "CONTEXT_DIR",
  454. "displayName": "Context Directory",
  455. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  456. },
  457. {
  458. "name": "APPLICATION_DOMAIN",
  459. "displayName": "Application Hostname",
  460. "description": "The exposed hostname that will route to the Node.js service, if left blank a value will be defaulted.",
  461. "value": ""
  462. },
  463. {
  464. "name": "GITHUB_WEBHOOK_SECRET",
  465. "displayName": "GitHub Webhook Secret",
  466. "description": "A secret string used to configure the GitHub webhook.",
  467. "generate": "expression",
  468. "from": "[a-zA-Z0-9]{40}"
  469. },
  470. {
  471. "name": "GENERIC_WEBHOOK_SECRET",
  472. "displayName": "Generic Webhook Secret",
  473. "description": "A secret string used to configure the Generic webhook.",
  474. "generate": "expression",
  475. "from": "[a-zA-Z0-9]{40}"
  476. },
  477. {
  478. "name": "DATABASE_SERVICE_NAME",
  479. "displayName": "Database Service Name",
  480. "required": true,
  481. "value": "mongodb"
  482. },
  483. {
  484. "name": "DATABASE_USER",
  485. "displayName": "MongoDB Username",
  486. "description": "Username for MongoDB user that will be used for accessing the database.",
  487. "generate": "expression",
  488. "from": "user[A-Z0-9]{3}"
  489. },
  490. {
  491. "name": "DATABASE_PASSWORD",
  492. "displayName": "MongoDB Password",
  493. "description": "Password for the MongoDB user.",
  494. "generate": "expression",
  495. "from": "[a-zA-Z0-9]{16}"
  496. },
  497. {
  498. "name": "DATABASE_NAME",
  499. "displayName": "Database Name",
  500. "required": true,
  501. "value": "sampledb"
  502. },
  503. {
  504. "name": "DATABASE_ADMIN_PASSWORD",
  505. "displayName": "Database Administrator Password",
  506. "description": "Password for the database admin user.",
  507. "generate": "expression",
  508. "from": "[a-zA-Z0-9]{16}"
  509. },
  510. {
  511. "name": "NPM_MIRROR",
  512. "displayName": "Custom NPM Mirror URL",
  513. "description": "The custom NPM mirror URL",
  514. "value": ""
  515. }
  516. ]
  517. }