dancer-mysql-persistent.json 15 KB

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