jws-tomcat7-postgresql-persistent-sti.json 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "annotations": {
  6. "iconClass" : "icon-tomcat",
  7. "description": "Application template for JWS PostgreSQL applications with persistent storage built using STI."
  8. },
  9. "name": "jws-tomcat7-postgresql-persistent-sti"
  10. },
  11. "labels": {
  12. "template": "jws-tomcat7-postgresql-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": "The maximum number of client connections allowed. This also sets the maximum number of prepared transactions.",
  93. "name": "POSTGRESQL_MAX_CONNECTIONS"
  94. },
  95. {
  96. "description": "Configures how much memory is dedicated to PostgreSQL for caching data.",
  97. "name": "POSTGRESQL_SHARED_BUFFERS"
  98. },
  99. {
  100. "description": "Database user name",
  101. "name": "DB_USERNAME",
  102. "from": "user[a-zA-Z0-9]{3}",
  103. "generate": "expression"
  104. },
  105. {
  106. "description": "Database user password",
  107. "name": "DB_PASSWORD",
  108. "from": "[a-zA-Z0-9]{8}",
  109. "generate": "expression"
  110. },
  111. {
  112. "description": "JWS Admin User",
  113. "name": "JWS_ADMIN_USERNAME",
  114. "from": "[a-zA-Z0-9]{8}",
  115. "generate": "expression"
  116. },
  117. {
  118. "description": "JWS Admin Password",
  119. "name": "JWS_ADMIN_PASSWORD",
  120. "from": "[a-zA-Z0-9]{8}",
  121. "generate": "expression"
  122. },
  123. {
  124. "description": "Github trigger secret",
  125. "name": "GITHUB_TRIGGER_SECRET",
  126. "from": "[a-zA-Z0-9]{8}",
  127. "generate": "expression"
  128. },
  129. {
  130. "description": "Generic build trigger secret",
  131. "name": "GENERIC_TRIGGER_SECRET",
  132. "from": "[a-zA-Z0-9]{8}",
  133. "generate": "expression"
  134. }
  135. ],
  136. "objects": [
  137. {
  138. "kind": "Service",
  139. "apiVersion": "v1",
  140. "spec": {
  141. "ports": [
  142. {
  143. "port": 8080,
  144. "targetPort": 8080
  145. }
  146. ],
  147. "selector": {
  148. "deploymentConfig": "${APPLICATION_NAME}"
  149. }
  150. },
  151. "metadata": {
  152. "name": "${APPLICATION_NAME}",
  153. "labels": {
  154. "application": "${APPLICATION_NAME}"
  155. },
  156. "annotations": {
  157. "description": "The web server's http port."
  158. }
  159. }
  160. },
  161. {
  162. "kind": "Service",
  163. "apiVersion": "v1",
  164. "spec": {
  165. "ports": [
  166. {
  167. "port": 8443,
  168. "targetPort": 8443
  169. }
  170. ],
  171. "selector": {
  172. "deploymentConfig": "${APPLICATION_NAME}"
  173. }
  174. },
  175. "metadata": {
  176. "name": "secure-${APPLICATION_NAME}",
  177. "labels": {
  178. "application": "${APPLICATION_NAME}"
  179. },
  180. "annotations": {
  181. "description": "The web server's https port."
  182. }
  183. }
  184. },
  185. {
  186. "kind": "Service",
  187. "apiVersion": "v1",
  188. "spec": {
  189. "ports": [
  190. {
  191. "port": 5432,
  192. "targetPort": 5432
  193. }
  194. ],
  195. "selector": {
  196. "deploymentConfig": "${APPLICATION_NAME}-postgresql"
  197. }
  198. },
  199. "metadata": {
  200. "name": "${APPLICATION_NAME}-postgresql",
  201. "labels": {
  202. "application": "${APPLICATION_NAME}"
  203. },
  204. "annotations": {
  205. "description": "The database server's port."
  206. }
  207. }
  208. },
  209. {
  210. "kind": "Route",
  211. "apiVersion": "v1",
  212. "id": "${APPLICATION_NAME}-http-route",
  213. "metadata": {
  214. "name": "${APPLICATION_NAME}-http-route",
  215. "labels": {
  216. "application": "${APPLICATION_NAME}"
  217. },
  218. "annotations": {
  219. "description": "Route for application's http service."
  220. }
  221. },
  222. "spec": {
  223. "host": "${APPLICATION_HOSTNAME}",
  224. "to": {
  225. "name": "${APPLICATION_NAME}"
  226. }
  227. }
  228. },
  229. {
  230. "kind": "Route",
  231. "apiVersion": "v1",
  232. "id": "${APPLICATION_NAME}-https-route",
  233. "metadata": {
  234. "name": "${APPLICATION_NAME}-https-route",
  235. "labels": {
  236. "application": "${APPLICATION_NAME}"
  237. },
  238. "annotations": {
  239. "description": "Route for application's https service."
  240. }
  241. },
  242. "spec": {
  243. "host": "${APPLICATION_HOSTNAME}",
  244. "to": {
  245. "name": "secure-${APPLICATION_NAME}"
  246. },
  247. "tls": {
  248. "termination" : "passthrough"
  249. }
  250. }
  251. },
  252. {
  253. "kind": "ImageStream",
  254. "apiVersion": "v1",
  255. "metadata": {
  256. "name": "${APPLICATION_NAME}",
  257. "labels": {
  258. "application": "${APPLICATION_NAME}"
  259. }
  260. }
  261. },
  262. {
  263. "kind": "BuildConfig",
  264. "apiVersion": "v1",
  265. "metadata": {
  266. "name": "${APPLICATION_NAME}",
  267. "labels": {
  268. "application": "${APPLICATION_NAME}"
  269. }
  270. },
  271. "spec": {
  272. "source": {
  273. "type": "Git",
  274. "git": {
  275. "uri": "${GIT_URI}",
  276. "ref": "${GIT_REF}"
  277. },
  278. "contextDir":"${GIT_CONTEXT_DIR}"
  279. },
  280. "strategy": {
  281. "type": "Source",
  282. "sourceStrategy": {
  283. "from": {
  284. "kind": "ImageStreamTag",
  285. "namespace": "openshift",
  286. "name": "jboss-webserver3-tomcat7-openshift:${JWS_RELEASE}"
  287. }
  288. }
  289. },
  290. "output": {
  291. "to": {
  292. "name": "${APPLICATION_NAME}"
  293. }
  294. },
  295. "triggers": [
  296. {
  297. "type": "github",
  298. "github": {
  299. "secret": "${GITHUB_TRIGGER_SECRET}"
  300. }
  301. },
  302. {
  303. "type": "generic",
  304. "generic": {
  305. "secret": "${GENERIC_TRIGGER_SECRET}"
  306. }
  307. },
  308. {
  309. "type": "imageChange",
  310. "imageChange": {}
  311. }
  312. ]
  313. }
  314. },
  315. {
  316. "kind": "DeploymentConfig",
  317. "apiVersion": "v1",
  318. "metadata": {
  319. "name": "${APPLICATION_NAME}",
  320. "labels": {
  321. "application": "${APPLICATION_NAME}"
  322. }
  323. },
  324. "spec": {
  325. "strategy": {
  326. "type": "Recreate"
  327. },
  328. "triggers": [
  329. {
  330. "type": "ImageChange",
  331. "imageChangeParams": {
  332. "automatic": true,
  333. "containerNames": [
  334. "${APPLICATION_NAME}"
  335. ],
  336. "from": {
  337. "kind": "ImageStream",
  338. "name": "${APPLICATION_NAME}"
  339. }
  340. }
  341. }
  342. ],
  343. "replicas": 1,
  344. "selector": {
  345. "deploymentConfig": "${APPLICATION_NAME}"
  346. },
  347. "template": {
  348. "metadata": {
  349. "name": "${APPLICATION_NAME}",
  350. "labels": {
  351. "deploymentConfig": "${APPLICATION_NAME}",
  352. "application": "${APPLICATION_NAME}"
  353. }
  354. },
  355. "spec": {
  356. "serviceAccount": "jws-service-account",
  357. "containers": [
  358. {
  359. "name": "${APPLICATION_NAME}",
  360. "image": "${APPLICATION_NAME}",
  361. "imagePullPolicy": "Always",
  362. "readinessProbe": {
  363. "exec": {
  364. "command": [
  365. "/bin/bash",
  366. "-c",
  367. "curl -s -u ${JWS_ADMIN_USERNAME}:${JWS_ADMIN_PASSWORD} 'http://localhost:8080/manager/jmxproxy/?get=Catalina%3Atype%3DServer&att=stateName' |grep -iq 'stateName *= *STARTED'"
  368. ]
  369. }
  370. },
  371. "volumeMounts": [
  372. {
  373. "name": "jws-certificate-volume",
  374. "mountPath": "/etc/jws-secret-volume",
  375. "readOnly": true
  376. }
  377. ],
  378. "ports": [
  379. {
  380. "name": "${APPLICATION_NAME}-tcp-8080",
  381. "containerPort": 8080,
  382. "protocol": "TCP"
  383. },
  384. {
  385. "name": "${APPLICATION_NAME}-tcp-8443",
  386. "containerPort": 8443,
  387. "protocol": "TCP"
  388. }
  389. ],
  390. "env": [
  391. {
  392. "name": "DB_SERVICE_PREFIX_MAPPING",
  393. "value": "${APPLICATION_NAME}-postgresql=DB"
  394. },
  395. {
  396. "name": "DB_JNDI",
  397. "value": "${DB_JNDI}"
  398. },
  399. {
  400. "name": "DB_USERNAME",
  401. "value": "${DB_USERNAME}"
  402. },
  403. {
  404. "name": "DB_PASSWORD",
  405. "value": "${DB_PASSWORD}"
  406. },
  407. {
  408. "name": "DB_DATABASE",
  409. "value": "${DB_DATABASE}"
  410. },
  411. {
  412. "name": "DB_MIN_POOL_SIZE",
  413. "value": "${DB_MIN_POOL_SIZE}"
  414. },
  415. {
  416. "name": "DB_MAX_POOL_SIZE",
  417. "value": "${DB_MAX_POOL_SIZE}"
  418. },
  419. {
  420. "name": "DB_TX_ISOLATION",
  421. "value": "${DB_TX_ISOLATION}"
  422. },
  423. {
  424. "name": "JWS_HTTPS_CERTIFICATE_DIR",
  425. "value": "/etc/jws-secret-volume"
  426. },
  427. {
  428. "name": "JWS_HTTPS_CERTIFICATE",
  429. "value": "${JWS_HTTPS_CERTIFICATE}"
  430. },
  431. {
  432. "name": "JWS_HTTPS_CERTIFICATE_KEY",
  433. "value": "${JWS_HTTPS_CERTIFICATE_KEY}"
  434. },
  435. {
  436. "name": "JWS_HTTPS_CERTIFICATE_PASSWORD",
  437. "value": "${JWS_HTTPS_CERTIFICATE_PASSWORD}"
  438. },
  439. {
  440. "name": "JWS_ADMIN_USERNAME",
  441. "value": "${JWS_ADMIN_USERNAME}"
  442. },
  443. {
  444. "name": "JWS_ADMIN_PASSWORD",
  445. "value": "${JWS_ADMIN_PASSWORD}"
  446. }
  447. ]
  448. }
  449. ],
  450. "volumes": [
  451. {
  452. "name": "jws-certificate-volume",
  453. "secret": {
  454. "secretName": "${JWS_HTTPS_SECRET}"
  455. }
  456. }
  457. ]
  458. }
  459. }
  460. }
  461. },
  462. {
  463. "kind": "DeploymentConfig",
  464. "apiVersion": "v1",
  465. "metadata": {
  466. "name": "${APPLICATION_NAME}-postgresql",
  467. "labels": {
  468. "application": "${APPLICATION_NAME}"
  469. }
  470. },
  471. "spec": {
  472. "strategy": {
  473. "type": "Recreate"
  474. },
  475. "triggers": [
  476. {
  477. "type": "ImageChange",
  478. "imageChangeParams": {
  479. "automatic": true,
  480. "containerNames": [
  481. "${APPLICATION_NAME}-postgresql"
  482. ],
  483. "from": {
  484. "kind": "ImageStreamTag",
  485. "namespace": "openshift",
  486. "name": "postgresql:latest"
  487. }
  488. }
  489. }
  490. ],
  491. "replicas": 1,
  492. "selector": {
  493. "deploymentConfig": "${APPLICATION_NAME}-postgresql"
  494. },
  495. "template": {
  496. "metadata": {
  497. "name": "${APPLICATION_NAME}-postgresql",
  498. "labels": {
  499. "deploymentConfig": "${APPLICATION_NAME}-postgresql",
  500. "application": "${APPLICATION_NAME}"
  501. }
  502. },
  503. "spec": {
  504. "containers": [
  505. {
  506. "name": "${APPLICATION_NAME}-postgresql",
  507. "image": "postgresql",
  508. "ports": [
  509. {
  510. "name": "${APPLICATION_NAME}-postgresql-tcp-5432",
  511. "containerPort": 5432,
  512. "protocol": "TCP"
  513. }
  514. ],
  515. "volumeMounts": [
  516. {
  517. "mountPath": "/var/lib/pgsql/data",
  518. "name": "${APPLICATION_NAME}-postgresql-pvol"
  519. }
  520. ],
  521. "env": [
  522. {
  523. "name": "POSTGRESQL_USER",
  524. "value": "${DB_USERNAME}"
  525. },
  526. {
  527. "name": "POSTGRESQL_PASSWORD",
  528. "value": "${DB_PASSWORD}"
  529. },
  530. {
  531. "name": "POSTGRESQL_DATABASE",
  532. "value": "${DB_DATABASE}"
  533. },
  534. {
  535. "name": "POSTGRESQL_MAX_CONNECTIONS",
  536. "value": "${POSTGRESQL_MAX_CONNECTIONS}"
  537. },
  538. {
  539. "name": "POSTGRESQL_SHARED_BUFFERS",
  540. "value": "${POSTGRESQL_SHARED_BUFFERS}"
  541. }
  542. ]
  543. }
  544. ],
  545. "volumes": [
  546. {
  547. "name": "${APPLICATION_NAME}-postgresql-pvol",
  548. "persistentVolumeClaim": {
  549. "claimName": "${APPLICATION_NAME}-postgresql-claim"
  550. }
  551. }
  552. ]
  553. }
  554. }
  555. }
  556. },
  557. {
  558. "apiVersion": "v1",
  559. "kind": "PersistentVolumeClaim",
  560. "metadata": {
  561. "name": "${APPLICATION_NAME}-postgresql-claim",
  562. "labels": {
  563. "application": "${APPLICATION_NAME}"
  564. }
  565. },
  566. "spec": {
  567. "accessModes": [ "ReadWriteOnce" ],
  568. "resources": {
  569. "requests": {
  570. "storage": "${VOLUME_CAPACITY}"
  571. }
  572. }
  573. }
  574. }
  575. ]
  576. }