jws-tomcat7-mongodb-persistent-sti.json 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "annotations": {
  6. "iconClass" : "icon-tomcat",
  7. "description": "Application template for JWS MongoDB applications with persistent storage built using STI."
  8. },
  9. "name": "jws-tomcat7-mongodb-persistent-sti"
  10. },
  11. "labels": {
  12. "template": "jws-tomcat7-mongodb-persistent-sti"
  13. },
  14. "parameters": [
  15. {
  16. "description": "JWS Release version, e.g. 3.0, 2.1, etc.",
  17. "name": "JWS_RELEASE",
  18. "value": "3.0"
  19. },
  20. {
  21. "description": "The name for the application.",
  22. "name": "APPLICATION_NAME",
  23. "value": "jws-app"
  24. },
  25. {
  26. "description": "Custom hostname for service routes. Leave blank for default hostname, e.g.: <application-name>.<project>.<default-domain-suffix>",
  27. "name": "APPLICATION_HOSTNAME",
  28. "value": ""
  29. },
  30. {
  31. "description": "Git source URI for application",
  32. "name": "GIT_URI"
  33. },
  34. {
  35. "description": "Git branch/tag reference",
  36. "name": "GIT_REF",
  37. "value": "master"
  38. },
  39. {
  40. "description": "Path within Git project to build; empty for root project directory.",
  41. "name": "GIT_CONTEXT_DIR",
  42. "value": ""
  43. },
  44. {
  45. "description": "Database JNDI name used by application to resolve the datasource, e.g. java:/jboss/datasources/mongodb",
  46. "name": "DB_JNDI",
  47. "value": ""
  48. },
  49. {
  50. "description": "Database name",
  51. "name": "DB_DATABASE",
  52. "value": "root"
  53. },
  54. {
  55. "description": "Size of persistent storage for database volume.",
  56. "name": "VOLUME_CAPACITY",
  57. "value": "512Mi"
  58. },
  59. {
  60. "description": "The name of the secret containing the certificate files",
  61. "name": "JWS_HTTPS_SECRET",
  62. "value": "jws-app-secret"
  63. },
  64. {
  65. "description": "The name of the certificate file within the secret",
  66. "name": "JWS_HTTPS_CERTIFICATE",
  67. "value": "server.crt"
  68. },
  69. {
  70. "description": "The name of the certificate key file within the secret",
  71. "name": "JWS_HTTPS_CERTIFICATE_KEY",
  72. "value": "server.key"
  73. },
  74. {
  75. "description": "The certificate password",
  76. "name": "JWS_HTTPS_CERTIFICATE_PASSWORD",
  77. "value": ""
  78. },
  79. {
  80. "description": "Sets xa-pool/min-pool-size for the configured datasource.",
  81. "name": "DB_MIN_POOL_SIZE"
  82. },
  83. {
  84. "description": "Sets xa-pool/max-pool-size for the configured datasource.",
  85. "name": "DB_MAX_POOL_SIZE"
  86. },
  87. {
  88. "description": "Sets transaction-isolation for the configured datasource.",
  89. "name": "DB_TX_ISOLATION"
  90. },
  91. {
  92. "description": "Disable data file preallocation.",
  93. "name": "MONGODB_NOPREALLOC"
  94. },
  95. {
  96. "description": "Set MongoDB to use a smaller default data file size.",
  97. "name": "MONGODB_SMALLFILES"
  98. },
  99. {
  100. "description": "Runs MongoDB in a quiet mode that attempts to limit the amount of output.",
  101. "name": "MONGODB_QUIET"
  102. },
  103. {
  104. "description": "Database user name",
  105. "name": "DB_USERNAME",
  106. "from": "user[a-zA-Z0-9]{3}",
  107. "generate": "expression"
  108. },
  109. {
  110. "description": "Database user password",
  111. "name": "DB_PASSWORD",
  112. "from": "[a-zA-Z0-9]{8}",
  113. "generate": "expression"
  114. },
  115. {
  116. "description": "Database admin password",
  117. "name": "DB_ADMIN_PASSWORD",
  118. "from": "[a-zA-Z0-9]{8}",
  119. "generate": "expression"
  120. },
  121. {
  122. "description": "JWS Admin User",
  123. "name": "JWS_ADMIN_USERNAME",
  124. "from": "[a-zA-Z0-9]{8}",
  125. "generate": "expression"
  126. },
  127. {
  128. "description": "JWS Admin Password",
  129. "name": "JWS_ADMIN_PASSWORD",
  130. "from": "[a-zA-Z0-9]{8}",
  131. "generate": "expression"
  132. },
  133. {
  134. "description": "Github trigger secret",
  135. "name": "GITHUB_TRIGGER_SECRET",
  136. "from": "[a-zA-Z0-9]{8}",
  137. "generate": "expression"
  138. },
  139. {
  140. "description": "Generic build trigger secret",
  141. "name": "GENERIC_TRIGGER_SECRET",
  142. "from": "[a-zA-Z0-9]{8}",
  143. "generate": "expression"
  144. }
  145. ],
  146. "objects": [
  147. {
  148. "kind": "Service",
  149. "apiVersion": "v1",
  150. "spec": {
  151. "ports": [
  152. {
  153. "port": 8080,
  154. "targetPort": 8080
  155. }
  156. ],
  157. "selector": {
  158. "deploymentConfig": "${APPLICATION_NAME}"
  159. }
  160. },
  161. "metadata": {
  162. "name": "${APPLICATION_NAME}",
  163. "labels": {
  164. "application": "${APPLICATION_NAME}"
  165. },
  166. "annotations": {
  167. "description": "The web server's http port."
  168. }
  169. }
  170. },
  171. {
  172. "kind": "Service",
  173. "apiVersion": "v1",
  174. "spec": {
  175. "ports": [
  176. {
  177. "port": 8443,
  178. "targetPort": 8443
  179. }
  180. ],
  181. "selector": {
  182. "deploymentConfig": "${APPLICATION_NAME}"
  183. }
  184. },
  185. "metadata": {
  186. "name": "secure-${APPLICATION_NAME}",
  187. "labels": {
  188. "application": "${APPLICATION_NAME}"
  189. },
  190. "annotations": {
  191. "description": "The web server's https port."
  192. }
  193. }
  194. },
  195. {
  196. "kind": "Service",
  197. "apiVersion": "v1",
  198. "spec": {
  199. "ports": [
  200. {
  201. "port": 27017,
  202. "targetPort": 27017
  203. }
  204. ],
  205. "selector": {
  206. "deploymentConfig": "${APPLICATION_NAME}-mongodb"
  207. }
  208. },
  209. "metadata": {
  210. "name": "${APPLICATION_NAME}-mongodb",
  211. "labels": {
  212. "application": "${APPLICATION_NAME}"
  213. },
  214. "annotations": {
  215. "description": "The database server's port."
  216. }
  217. }
  218. },
  219. {
  220. "kind": "Route",
  221. "apiVersion": "v1",
  222. "id": "${APPLICATION_NAME}-http-route",
  223. "metadata": {
  224. "name": "${APPLICATION_NAME}-http-route",
  225. "labels": {
  226. "application": "${APPLICATION_NAME}"
  227. },
  228. "annotations": {
  229. "description": "Route for application's http service."
  230. }
  231. },
  232. "spec": {
  233. "host": "${APPLICATION_HOSTNAME}",
  234. "to": {
  235. "name": "${APPLICATION_NAME}"
  236. }
  237. }
  238. },
  239. {
  240. "kind": "Route",
  241. "apiVersion": "v1",
  242. "id": "${APPLICATION_NAME}-https-route",
  243. "metadata": {
  244. "name": "${APPLICATION_NAME}-https-route",
  245. "labels": {
  246. "application": "${APPLICATION_NAME}"
  247. },
  248. "annotations": {
  249. "description": "Route for application's https service."
  250. }
  251. },
  252. "spec": {
  253. "host": "${APPLICATION_HOSTNAME}",
  254. "to": {
  255. "name": "secure-${APPLICATION_NAME}"
  256. },
  257. "tls": {
  258. "termination" : "passthrough"
  259. }
  260. }
  261. },
  262. {
  263. "kind": "ImageStream",
  264. "apiVersion": "v1",
  265. "metadata": {
  266. "name": "${APPLICATION_NAME}",
  267. "labels": {
  268. "application": "${APPLICATION_NAME}"
  269. }
  270. }
  271. },
  272. {
  273. "kind": "BuildConfig",
  274. "apiVersion": "v1",
  275. "metadata": {
  276. "name": "${APPLICATION_NAME}",
  277. "labels": {
  278. "application": "${APPLICATION_NAME}"
  279. }
  280. },
  281. "spec": {
  282. "source": {
  283. "type": "Git",
  284. "git": {
  285. "uri": "${GIT_URI}",
  286. "ref": "${GIT_REF}"
  287. },
  288. "contextDir":"${GIT_CONTEXT_DIR}"
  289. },
  290. "strategy": {
  291. "type": "Source",
  292. "sourceStrategy": {
  293. "from": {
  294. "kind": "ImageStreamTag",
  295. "namespace": "openshift",
  296. "name": "jboss-webserver3-tomcat7-openshift:${JWS_RELEASE}"
  297. }
  298. }
  299. },
  300. "output": {
  301. "to": {
  302. "kind": "ImageStreamTag",
  303. "name": "${APPLICATION_NAME}:latest"
  304. }
  305. },
  306. "triggers": [
  307. {
  308. "type": "GitHub",
  309. "github": {
  310. "secret": "${GITHUB_TRIGGER_SECRET}"
  311. }
  312. },
  313. {
  314. "type": "Generic",
  315. "generic": {
  316. "secret": "${GENERIC_TRIGGER_SECRET}"
  317. }
  318. },
  319. {
  320. "type": "ImageChange",
  321. "imageChange": {}
  322. }
  323. ]
  324. }
  325. },
  326. {
  327. "kind": "DeploymentConfig",
  328. "apiVersion": "v1",
  329. "metadata": {
  330. "name": "${APPLICATION_NAME}",
  331. "labels": {
  332. "application": "${APPLICATION_NAME}"
  333. }
  334. },
  335. "spec": {
  336. "strategy": {
  337. "type": "Recreate"
  338. },
  339. "triggers": [
  340. {
  341. "type": "ImageChange",
  342. "imageChangeParams": {
  343. "automatic": true,
  344. "containerNames": [
  345. "${APPLICATION_NAME}"
  346. ],
  347. "from": {
  348. "kind": "ImageStream",
  349. "name": "${APPLICATION_NAME}"
  350. }
  351. }
  352. }
  353. ],
  354. "replicas": 1,
  355. "selector": {
  356. "deploymentConfig": "${APPLICATION_NAME}"
  357. },
  358. "template": {
  359. "metadata": {
  360. "name": "${APPLICATION_NAME}",
  361. "labels": {
  362. "deploymentConfig": "${APPLICATION_NAME}",
  363. "application": "${APPLICATION_NAME}"
  364. }
  365. },
  366. "spec": {
  367. "serviceAccount": "jws-service-account",
  368. "containers": [
  369. {
  370. "name": "${APPLICATION_NAME}",
  371. "image": "${APPLICATION_NAME}",
  372. "imagePullPolicy": "Always",
  373. "readinessProbe": {
  374. "exec": {
  375. "command": [
  376. "/bin/bash",
  377. "-c",
  378. "curl -s -u ${JWS_ADMIN_USERNAME}:${JWS_ADMIN_PASSWORD} 'http://localhost:8080/manager/jmxproxy/?get=Catalina%3Atype%3DServer&att=stateName' |grep -iq 'stateName *= *STARTED'"
  379. ]
  380. }
  381. },
  382. "volumeMounts": [
  383. {
  384. "name": "jws-certificate-volume",
  385. "mountPath": "/etc/jws-secret-volume",
  386. "readOnly": true
  387. }
  388. ],
  389. "ports": [
  390. {
  391. "name": "http",
  392. "containerPort": 8080,
  393. "protocol": "TCP"
  394. },
  395. {
  396. "name": "https",
  397. "containerPort": 8443,
  398. "protocol": "TCP"
  399. }
  400. ],
  401. "env": [
  402. {
  403. "name": "DB_SERVICE_PREFIX_MAPPING",
  404. "value": "${APPLICATION_NAME}-mongodb=DB"
  405. },
  406. {
  407. "name": "DB_JNDI",
  408. "value": "${DB_JNDI}"
  409. },
  410. {
  411. "name": "DB_USERNAME",
  412. "value": "${DB_USERNAME}"
  413. },
  414. {
  415. "name": "DB_PASSWORD",
  416. "value": "${DB_PASSWORD}"
  417. },
  418. {
  419. "name": "DB_DATABASE",
  420. "value": "${DB_DATABASE}"
  421. },
  422. {
  423. "name": "DB_ADMIN_PASSWORD",
  424. "value": "${DB_ADMIN_PASSWORD}"
  425. },
  426. {
  427. "name": "DB_MIN_POOL_SIZE",
  428. "value": "${DB_MIN_POOL_SIZE}"
  429. },
  430. {
  431. "name": "DB_MAX_POOL_SIZE",
  432. "value": "${DB_MAX_POOL_SIZE}"
  433. },
  434. {
  435. "name": "DB_TX_ISOLATION",
  436. "value": "${DB_TX_ISOLATION}"
  437. },
  438. {
  439. "name": "JWS_HTTPS_CERTIFICATE_DIR",
  440. "value": "/etc/jws-secret-volume"
  441. },
  442. {
  443. "name": "JWS_HTTPS_CERTIFICATE",
  444. "value": "${JWS_HTTPS_CERTIFICATE}"
  445. },
  446. {
  447. "name": "JWS_HTTPS_CERTIFICATE_KEY",
  448. "value": "${JWS_HTTPS_CERTIFICATE_KEY}"
  449. },
  450. {
  451. "name": "JWS_HTTPS_CERTIFICATE_PASSWORD",
  452. "value": "${JWS_HTTPS_CERTIFICATE_PASSWORD}"
  453. },
  454. {
  455. "name": "JWS_ADMIN_USERNAME",
  456. "value": "${JWS_ADMIN_USERNAME}"
  457. },
  458. {
  459. "name": "JWS_ADMIN_PASSWORD",
  460. "value": "${JWS_ADMIN_PASSWORD}"
  461. }
  462. ]
  463. }
  464. ],
  465. "volumes": [
  466. {
  467. "name": "jws-certificate-volume",
  468. "secret": {
  469. "secretName": "${JWS_HTTPS_SECRET}"
  470. }
  471. }
  472. ]
  473. }
  474. }
  475. }
  476. },
  477. {
  478. "kind": "DeploymentConfig",
  479. "apiVersion": "v1",
  480. "metadata": {
  481. "name": "${APPLICATION_NAME}-mongodb",
  482. "labels": {
  483. "application": "${APPLICATION_NAME}"
  484. }
  485. },
  486. "spec": {
  487. "strategy": {
  488. "type": "Recreate"
  489. },
  490. "triggers": [
  491. {
  492. "type": "ImageChange",
  493. "imageChangeParams": {
  494. "automatic": true,
  495. "containerNames": [
  496. "${APPLICATION_NAME}-mongodb"
  497. ],
  498. "from": {
  499. "kind": "ImageStreamTag",
  500. "namespace": "openshift",
  501. "name": "mongodb:latest"
  502. }
  503. }
  504. }
  505. ],
  506. "replicas": 1,
  507. "selector": {
  508. "deploymentConfig": "${APPLICATION_NAME}-mongodb"
  509. },
  510. "template": {
  511. "metadata": {
  512. "name": "${APPLICATION_NAME}-mongodb",
  513. "labels": {
  514. "deploymentConfig": "${APPLICATION_NAME}-mongodb",
  515. "application": "${APPLICATION_NAME}"
  516. }
  517. },
  518. "spec": {
  519. "containers": [
  520. {
  521. "name": "${APPLICATION_NAME}-mongodb",
  522. "image": "mongodb",
  523. "imagePullPolicy": "Always",
  524. "ports": [
  525. {
  526. "containerPort": 27017,
  527. "protocol": "TCP"
  528. }
  529. ],
  530. "volumeMounts": [
  531. {
  532. "mountPath": "/var/lib/mongodb/data",
  533. "name": "${APPLICATION_NAME}-mongodb-pvol"
  534. }
  535. ],
  536. "env": [
  537. {
  538. "name": "MONGODB_USER",
  539. "value": "${DB_USERNAME}"
  540. },
  541. {
  542. "name": "MONGODB_PASSWORD",
  543. "value": "${DB_PASSWORD}"
  544. },
  545. {
  546. "name": "MONGODB_DATABASE",
  547. "value": "${DB_DATABASE}"
  548. },
  549. {
  550. "name": "MONGODB_ADMIN_PASSWORD",
  551. "value": "${DB_ADMIN_PASSWORD}"
  552. },
  553. {
  554. "name": "MONGODB_NOPREALLOC",
  555. "value": "${MONGODB_NOPREALLOC}"
  556. },
  557. {
  558. "name": "MONGODB_SMALLFILES",
  559. "value": "${MONGODB_SMALLFILES}"
  560. },
  561. {
  562. "name": "MONGODB_QUIET",
  563. "value": "${MONGODB_QUIET}"
  564. }
  565. ]
  566. }
  567. ],
  568. "volumes": [
  569. {
  570. "name": "${APPLICATION_NAME}-mongodb-pvol",
  571. "persistentVolumeClaim": {
  572. "claimName": "${APPLICATION_NAME}-mongodb-claim"
  573. }
  574. }
  575. ]
  576. }
  577. }
  578. }
  579. },
  580. {
  581. "apiVersion": "v1",
  582. "kind": "PersistentVolumeClaim",
  583. "metadata": {
  584. "name": "${APPLICATION_NAME}-mongodb-claim",
  585. "labels": {
  586. "application": "${APPLICATION_NAME}"
  587. }
  588. },
  589. "spec": {
  590. "accessModes": [ "ReadWriteOnce" ],
  591. "resources": {
  592. "requests": {
  593. "storage": "${VOLUME_CAPACITY}"
  594. }
  595. }
  596. }
  597. }
  598. ]
  599. }