dancer-mysql-persistent.json 15 KB

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