dancer-mysql-persistent.json 15 KB

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