dancer-mysql-persistent.json 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "dancer-mysql-persistent",
  6. "annotations": {
  7. "openshift.io/display-name": "Dancer + MySQL (Persistent)",
  8. "description": "An example Dancer application with a MySQL database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/dancer-ex/blob/master/README.md.",
  9. "tags": "quickstart,perl,dancer",
  10. "iconClass": "icon-perl"
  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/dancer-ex/blob/master/README.md.",
  14. "labels": {
  15. "template": "dancer-mysql-persistent"
  16. },
  17. "objects": [
  18. {
  19. "kind": "Secret",
  20. "apiVersion": "v1",
  21. "metadata": {
  22. "name": "${NAME}"
  23. },
  24. "stringData" : {
  25. "database-user" : "${DATABASE_USER}",
  26. "database-password" : "${DATABASE_PASSWORD}",
  27. "keybase" : "${SECRET_KEY_BASE}"
  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": "perl:5.24"
  102. },
  103. "env": [
  104. {
  105. "name": "CPAN_MIRROR",
  106. "value": "${CPAN_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. "postCommit": {
  132. "script": "perl -I extlib/lib/perl5 -I lib t/*"
  133. }
  134. }
  135. },
  136. {
  137. "kind": "DeploymentConfig",
  138. "apiVersion": "v1",
  139. "metadata": {
  140. "name": "${NAME}",
  141. "annotations": {
  142. "description": "Defines how to deploy the application server"
  143. }
  144. },
  145. "spec": {
  146. "triggers": [
  147. {
  148. "type": "ImageChange",
  149. "imageChangeParams": {
  150. "automatic": true,
  151. "containerNames": [
  152. "dancer-mysql-persistent"
  153. ],
  154. "from": {
  155. "kind": "ImageStreamTag",
  156. "name": "${NAME}:latest"
  157. }
  158. }
  159. },
  160. {
  161. "type": "ConfigChange"
  162. }
  163. ],
  164. "replicas": 1,
  165. "selector": {
  166. "name": "${NAME}"
  167. },
  168. "template": {
  169. "metadata": {
  170. "name": "${NAME}",
  171. "labels": {
  172. "name": "${NAME}"
  173. }
  174. },
  175. "spec": {
  176. "containers": [
  177. {
  178. "name": "dancer-mysql-persistent",
  179. "image": " ",
  180. "ports": [
  181. {
  182. "containerPort": 8080
  183. }
  184. ],
  185. "readinessProbe": {
  186. "timeoutSeconds": 3,
  187. "initialDelaySeconds": 3,
  188. "httpGet": {
  189. "path": "/health",
  190. "port": 8080
  191. }
  192. },
  193. "livenessProbe": {
  194. "timeoutSeconds": 3,
  195. "initialDelaySeconds": 30,
  196. "httpGet": {
  197. "path": "/",
  198. "port": 8080
  199. }
  200. },
  201. "env": [
  202. {
  203. "name": "DATABASE_SERVICE_NAME",
  204. "value": "${DATABASE_SERVICE_NAME}"
  205. },
  206. {
  207. "name": "MYSQL_USER",
  208. "valueFrom": {
  209. "secretKeyRef" : {
  210. "name" : "${NAME}",
  211. "key" : "database-user"
  212. }
  213. }
  214. },
  215. {
  216. "name": "MYSQL_PASSWORD",
  217. "valueFrom": {
  218. "secretKeyRef" : {
  219. "name" : "${NAME}",
  220. "key" : "database-password"
  221. }
  222. }
  223. },
  224. {
  225. "name": "MYSQL_DATABASE",
  226. "value": "${DATABASE_NAME}"
  227. },
  228. {
  229. "name": "SECRET_KEY_BASE",
  230. "valueFrom": {
  231. "secretKeyRef" : {
  232. "name" : "${NAME}",
  233. "key" : "keybase"
  234. }
  235. }
  236. },
  237. {
  238. "name": "PERL_APACHE2_RELOAD",
  239. "value": "${PERL_APACHE2_RELOAD}"
  240. }
  241. ],
  242. "resources": {
  243. "limits": {
  244. "memory": "${MEMORY_LIMIT}"
  245. }
  246. }
  247. }
  248. ]
  249. }
  250. }
  251. }
  252. },
  253. {
  254. "kind": "PersistentVolumeClaim",
  255. "apiVersion": "v1",
  256. "metadata": {
  257. "name": "${DATABASE_SERVICE_NAME}"
  258. },
  259. "spec": {
  260. "accessModes": [
  261. "ReadWriteOnce"
  262. ],
  263. "resources": {
  264. "requests": {
  265. "storage": "${VOLUME_CAPACITY}"
  266. }
  267. }
  268. }
  269. },
  270. {
  271. "kind": "Service",
  272. "apiVersion": "v1",
  273. "metadata": {
  274. "name": "${DATABASE_SERVICE_NAME}",
  275. "annotations": {
  276. "description": "Exposes the database server"
  277. }
  278. },
  279. "spec": {
  280. "ports": [
  281. {
  282. "name": "mysql",
  283. "port": 3306,
  284. "targetPort": 3306
  285. }
  286. ],
  287. "selector": {
  288. "name": "${DATABASE_SERVICE_NAME}"
  289. }
  290. }
  291. },
  292. {
  293. "kind": "DeploymentConfig",
  294. "apiVersion": "v1",
  295. "metadata": {
  296. "name": "${DATABASE_SERVICE_NAME}",
  297. "annotations": {
  298. "description": "Defines how to deploy the database"
  299. }
  300. },
  301. "spec": {
  302. "strategy": {
  303. "type": "Recreate"
  304. },
  305. "triggers": [
  306. {
  307. "type": "ImageChange",
  308. "imageChangeParams": {
  309. "automatic": true,
  310. "containerNames": [
  311. "mysql"
  312. ],
  313. "from": {
  314. "kind": "ImageStreamTag",
  315. "namespace": "${NAMESPACE}",
  316. "name": "mysql:5.7"
  317. }
  318. }
  319. },
  320. {
  321. "type": "ConfigChange"
  322. }
  323. ],
  324. "replicas": 1,
  325. "selector": {
  326. "name": "${DATABASE_SERVICE_NAME}"
  327. },
  328. "template": {
  329. "metadata": {
  330. "name": "${DATABASE_SERVICE_NAME}",
  331. "labels": {
  332. "name": "${DATABASE_SERVICE_NAME}"
  333. }
  334. },
  335. "spec": {
  336. "volumes": [
  337. {
  338. "name": "${DATABASE_SERVICE_NAME}-data",
  339. "persistentVolumeClaim": {
  340. "claimName": "${DATABASE_SERVICE_NAME}"
  341. }
  342. }
  343. ],
  344. "containers": [
  345. {
  346. "name": "mysql",
  347. "image": " ",
  348. "ports": [
  349. {
  350. "containerPort": 3306
  351. }
  352. ],
  353. "volumeMounts": [
  354. {
  355. "name": "${DATABASE_SERVICE_NAME}-data",
  356. "mountPath": "/var/lib/mysql/data"
  357. }
  358. ],
  359. "readinessProbe": {
  360. "timeoutSeconds": 1,
  361. "initialDelaySeconds": 5,
  362. "exec": {
  363. "command": [ "/bin/sh", "-i", "-c", "MYSQL_PWD='${DATABASE_PASSWORD}' mysql -h 127.0.0.1 -u ${DATABASE_USER} -D ${DATABASE_NAME} -e 'SELECT 1'" ]
  364. }
  365. },
  366. "livenessProbe": {
  367. "timeoutSeconds": 1,
  368. "initialDelaySeconds": 30,
  369. "tcpSocket": {
  370. "port": 3306
  371. }
  372. },
  373. "env": [
  374. {
  375. "name": "MYSQL_USER",
  376. "valueFrom": {
  377. "secretKeyRef" : {
  378. "name" : "${NAME}",
  379. "key" : "database-user"
  380. }
  381. }
  382. },
  383. {
  384. "name": "MYSQL_PASSWORD",
  385. "valueFrom": {
  386. "secretKeyRef" : {
  387. "name" : "${NAME}",
  388. "key" : "database-password"
  389. }
  390. }
  391. },
  392. {
  393. "name": "MYSQL_DATABASE",
  394. "value": "${DATABASE_NAME}"
  395. }
  396. ],
  397. "resources": {
  398. "limits": {
  399. "memory": "${MEMORY_MYSQL_LIMIT}"
  400. }
  401. }
  402. }
  403. ]
  404. }
  405. }
  406. }
  407. }
  408. ],
  409. "parameters": [
  410. {
  411. "name": "NAME",
  412. "displayName": "Name",
  413. "description": "The name assigned to all of the frontend objects defined in this template.",
  414. "required": true,
  415. "value": "dancer-mysql-persistent"
  416. },
  417. {
  418. "name": "NAMESPACE",
  419. "displayName": "Namespace",
  420. "description": "The OpenShift Namespace where the ImageStream resides.",
  421. "required": true,
  422. "value": "openshift"
  423. },
  424. {
  425. "name": "MEMORY_LIMIT",
  426. "displayName": "Memory Limit",
  427. "description": "Maximum amount of memory the Perl Dancer container can use.",
  428. "required": true,
  429. "value": "512Mi"
  430. },
  431. {
  432. "name": "MEMORY_MYSQL_LIMIT",
  433. "displayName": "Memory Limit (MySQL)",
  434. "description": "Maximum amount of memory the MySQL container can use.",
  435. "required": true,
  436. "value": "512Mi"
  437. },
  438. {
  439. "name": "VOLUME_CAPACITY",
  440. "displayName": "Volume Capacity",
  441. "description": "Volume space available for data, e.g. 512Mi, 2Gi",
  442. "value": "1Gi",
  443. "required": true
  444. },
  445. {
  446. "name": "SOURCE_REPOSITORY_URL",
  447. "displayName": "Git Repository URL",
  448. "description": "The URL of the repository with your application source code.",
  449. "required": true,
  450. "value": "https://github.com/openshift/dancer-ex.git"
  451. },
  452. {
  453. "name": "SOURCE_REPOSITORY_REF",
  454. "displayName": "Git Reference",
  455. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  456. },
  457. {
  458. "name": "CONTEXT_DIR",
  459. "displayName": "Context Directory",
  460. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  461. },
  462. {
  463. "name": "APPLICATION_DOMAIN",
  464. "displayName": "Application Hostname",
  465. "description": "The exposed hostname that will route to the Dancer service, if left blank a value will be defaulted.",
  466. "value": ""
  467. },
  468. {
  469. "name": "GITHUB_WEBHOOK_SECRET",
  470. "displayName": "GitHub Webhook Secret",
  471. "description": "A secret string used to configure the GitHub webhook.",
  472. "generate": "expression",
  473. "from": "[a-zA-Z0-9]{40}"
  474. },
  475. {
  476. "name": "DATABASE_SERVICE_NAME",
  477. "displayName": "Database Service Name",
  478. "required": true,
  479. "value": "database"
  480. },
  481. {
  482. "name": "DATABASE_USER",
  483. "displayName": "Database Username",
  484. "generate": "expression",
  485. "from": "user[A-Z0-9]{3}"
  486. },
  487. {
  488. "name": "DATABASE_PASSWORD",
  489. "displayName": "Database Password",
  490. "generate": "expression",
  491. "from": "[a-zA-Z0-9]{8}"
  492. },
  493. {
  494. "name": "DATABASE_NAME",
  495. "displayName": "Database Name",
  496. "required": true,
  497. "value": "sampledb"
  498. },
  499. {
  500. "name": "PERL_APACHE2_RELOAD",
  501. "displayName": "Perl Module Reload",
  502. "description": "Set this to \"true\" to enable automatic reloading of modified Perl modules.",
  503. "value": ""
  504. },
  505. {
  506. "name": "SECRET_KEY_BASE",
  507. "displayName": "Secret Key",
  508. "description": "Your secret key for verifying the integrity of signed cookies.",
  509. "generate": "expression",
  510. "from": "[a-z0-9]{127}"
  511. },
  512. {
  513. "name": "CPAN_MIRROR",
  514. "displayName": "Custom CPAN Mirror URL",
  515. "description": "The custom CPAN mirror URL",
  516. "value": ""
  517. }
  518. ]
  519. }