dancer-mysql-persistent.json 15 KB

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