jws-tomcat8-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-tomcat8-postgresql-persistent-sti"
  10. },
  11. "labels": {
  12. "template": "jws-tomcat8-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-tomcat8-openshift:${JWS_RELEASE}"
  287. }
  288. }
  289. },
  290. "output": {
  291. "to": {
  292. "kind": "ImageStreamTag",
  293. "name": "${APPLICATION_NAME}:latest"
  294. }
  295. },
  296. "triggers": [
  297. {
  298. "type": "GitHub",
  299. "github": {
  300. "secret": "${GITHUB_TRIGGER_SECRET}"
  301. }
  302. },
  303. {
  304. "type": "Generic",
  305. "generic": {
  306. "secret": "${GENERIC_TRIGGER_SECRET}"
  307. }
  308. },
  309. {
  310. "type": "ImageChange",
  311. "imageChange": {}
  312. }
  313. ]
  314. }
  315. },
  316. {
  317. "kind": "DeploymentConfig",
  318. "apiVersion": "v1",
  319. "metadata": {
  320. "name": "${APPLICATION_NAME}",
  321. "labels": {
  322. "application": "${APPLICATION_NAME}"
  323. }
  324. },
  325. "spec": {
  326. "strategy": {
  327. "type": "Recreate"
  328. },
  329. "triggers": [
  330. {
  331. "type": "ImageChange",
  332. "imageChangeParams": {
  333. "automatic": true,
  334. "containerNames": [
  335. "${APPLICATION_NAME}"
  336. ],
  337. "from": {
  338. "kind": "ImageStream",
  339. "name": "${APPLICATION_NAME}"
  340. }
  341. }
  342. }
  343. ],
  344. "replicas": 1,
  345. "selector": {
  346. "deploymentConfig": "${APPLICATION_NAME}"
  347. },
  348. "template": {
  349. "metadata": {
  350. "name": "${APPLICATION_NAME}",
  351. "labels": {
  352. "deploymentConfig": "${APPLICATION_NAME}",
  353. "application": "${APPLICATION_NAME}"
  354. }
  355. },
  356. "spec": {
  357. "serviceAccount": "jws-service-account",
  358. "containers": [
  359. {
  360. "name": "${APPLICATION_NAME}",
  361. "image": "${APPLICATION_NAME}",
  362. "imagePullPolicy": "Always",
  363. "readinessProbe": {
  364. "exec": {
  365. "command": [
  366. "/bin/bash",
  367. "-c",
  368. "curl -s -u ${JWS_ADMIN_USERNAME}:${JWS_ADMIN_PASSWORD} 'http://localhost:8080/manager/jmxproxy/?get=Catalina%3Atype%3DServer&att=stateName' |grep -iq 'stateName *= *STARTED'"
  369. ]
  370. }
  371. },
  372. "volumeMounts": [
  373. {
  374. "name": "jws-certificate-volume",
  375. "mountPath": "/etc/jws-secret-volume",
  376. "readOnly": true
  377. }
  378. ],
  379. "ports": [
  380. {
  381. "name": "http",
  382. "containerPort": 8080,
  383. "protocol": "TCP"
  384. },
  385. {
  386. "name": "https",
  387. "containerPort": 8443,
  388. "protocol": "TCP"
  389. }
  390. ],
  391. "env": [
  392. {
  393. "name": "DB_SERVICE_PREFIX_MAPPING",
  394. "value": "${APPLICATION_NAME}-postgresql=DB"
  395. },
  396. {
  397. "name": "DB_JNDI",
  398. "value": "${DB_JNDI}"
  399. },
  400. {
  401. "name": "DB_USERNAME",
  402. "value": "${DB_USERNAME}"
  403. },
  404. {
  405. "name": "DB_PASSWORD",
  406. "value": "${DB_PASSWORD}"
  407. },
  408. {
  409. "name": "DB_DATABASE",
  410. "value": "${DB_DATABASE}"
  411. },
  412. {
  413. "name": "DB_MIN_POOL_SIZE",
  414. "value": "${DB_MIN_POOL_SIZE}"
  415. },
  416. {
  417. "name": "DB_MAX_POOL_SIZE",
  418. "value": "${DB_MAX_POOL_SIZE}"
  419. },
  420. {
  421. "name": "DB_TX_ISOLATION",
  422. "value": "${DB_TX_ISOLATION}"
  423. },
  424. {
  425. "name": "JWS_HTTPS_CERTIFICATE_DIR",
  426. "value": "/etc/jws-secret-volume"
  427. },
  428. {
  429. "name": "JWS_HTTPS_CERTIFICATE",
  430. "value": "${JWS_HTTPS_CERTIFICATE}"
  431. },
  432. {
  433. "name": "JWS_HTTPS_CERTIFICATE_KEY",
  434. "value": "${JWS_HTTPS_CERTIFICATE_KEY}"
  435. },
  436. {
  437. "name": "JWS_HTTPS_CERTIFICATE_PASSWORD",
  438. "value": "${JWS_HTTPS_CERTIFICATE_PASSWORD}"
  439. },
  440. {
  441. "name": "JWS_ADMIN_USERNAME",
  442. "value": "${JWS_ADMIN_USERNAME}"
  443. },
  444. {
  445. "name": "JWS_ADMIN_PASSWORD",
  446. "value": "${JWS_ADMIN_PASSWORD}"
  447. }
  448. ]
  449. }
  450. ],
  451. "volumes": [
  452. {
  453. "name": "jws-certificate-volume",
  454. "secret": {
  455. "secretName": "${JWS_HTTPS_SECRET}"
  456. }
  457. }
  458. ]
  459. }
  460. }
  461. }
  462. },
  463. {
  464. "kind": "DeploymentConfig",
  465. "apiVersion": "v1",
  466. "metadata": {
  467. "name": "${APPLICATION_NAME}-postgresql",
  468. "labels": {
  469. "application": "${APPLICATION_NAME}"
  470. }
  471. },
  472. "spec": {
  473. "strategy": {
  474. "type": "Recreate"
  475. },
  476. "triggers": [
  477. {
  478. "type": "ImageChange",
  479. "imageChangeParams": {
  480. "automatic": true,
  481. "containerNames": [
  482. "${APPLICATION_NAME}-postgresql"
  483. ],
  484. "from": {
  485. "kind": "ImageStreamTag",
  486. "namespace": "openshift",
  487. "name": "postgresql:latest"
  488. }
  489. }
  490. }
  491. ],
  492. "replicas": 1,
  493. "selector": {
  494. "deploymentConfig": "${APPLICATION_NAME}-postgresql"
  495. },
  496. "template": {
  497. "metadata": {
  498. "name": "${APPLICATION_NAME}-postgresql",
  499. "labels": {
  500. "deploymentConfig": "${APPLICATION_NAME}-postgresql",
  501. "application": "${APPLICATION_NAME}"
  502. }
  503. },
  504. "spec": {
  505. "containers": [
  506. {
  507. "name": "${APPLICATION_NAME}-postgresql",
  508. "image": "postgresql",
  509. "ports": [
  510. {
  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. }