dancer-mysql.json 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "dancer-mysql-example",
  6. "annotations": {
  7. "openshift.io/display-name": "Dancer + MySQL (Ephemeral)",
  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.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing.",
  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. The database is stored in non-persistent storage, so this configuration should be used for experimental purposes only.",
  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-example"
  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-example"
  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-example",
  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": "Service",
  259. "apiVersion": "v1",
  260. "metadata": {
  261. "name": "${DATABASE_SERVICE_NAME}",
  262. "annotations": {
  263. "description": "Exposes the database server"
  264. }
  265. },
  266. "spec": {
  267. "ports": [
  268. {
  269. "name": "mysql",
  270. "port": 3306,
  271. "targetPort": 3306
  272. }
  273. ],
  274. "selector": {
  275. "name": "${DATABASE_SERVICE_NAME}"
  276. }
  277. }
  278. },
  279. {
  280. "kind": "DeploymentConfig",
  281. "apiVersion": "v1",
  282. "metadata": {
  283. "name": "${DATABASE_SERVICE_NAME}",
  284. "annotations": {
  285. "description": "Defines how to deploy the database"
  286. }
  287. },
  288. "spec": {
  289. "strategy": {
  290. "type": "Recreate"
  291. },
  292. "triggers": [
  293. {
  294. "type": "ImageChange",
  295. "imageChangeParams": {
  296. "automatic": true,
  297. "containerNames": [
  298. "mysql"
  299. ],
  300. "from": {
  301. "kind": "ImageStreamTag",
  302. "namespace": "${NAMESPACE}",
  303. "name": "mysql:5.7"
  304. }
  305. }
  306. },
  307. {
  308. "type": "ConfigChange"
  309. }
  310. ],
  311. "replicas": 1,
  312. "selector": {
  313. "name": "${DATABASE_SERVICE_NAME}"
  314. },
  315. "template": {
  316. "metadata": {
  317. "name": "${DATABASE_SERVICE_NAME}",
  318. "labels": {
  319. "name": "${DATABASE_SERVICE_NAME}"
  320. }
  321. },
  322. "spec": {
  323. "volumes": [
  324. {
  325. "name": "data",
  326. "emptyDir": {}
  327. }
  328. ],
  329. "containers": [
  330. {
  331. "name": "mysql",
  332. "image": " ",
  333. "ports": [
  334. {
  335. "containerPort": 3306
  336. }
  337. ],
  338. "volumeMounts": [
  339. {
  340. "name": "data",
  341. "mountPath": "/var/lib/mysql/data"
  342. }
  343. ],
  344. "readinessProbe": {
  345. "timeoutSeconds": 1,
  346. "initialDelaySeconds": 5,
  347. "exec": {
  348. "command": [ "/bin/sh", "-i", "-c", "MYSQL_PWD='${DATABASE_PASSWORD}' mysql -h 127.0.0.1 -u ${DATABASE_USER} -D ${DATABASE_NAME} -e 'SELECT 1'" ]
  349. }
  350. },
  351. "livenessProbe": {
  352. "timeoutSeconds": 1,
  353. "initialDelaySeconds": 30,
  354. "tcpSocket": {
  355. "port": 3306
  356. }
  357. },
  358. "env": [
  359. {
  360. "name": "MYSQL_USER",
  361. "valueFrom": {
  362. "secretKeyRef" : {
  363. "name" : "${NAME}",
  364. "key" : "database-user"
  365. }
  366. }
  367. },
  368. {
  369. "name": "MYSQL_PASSWORD",
  370. "valueFrom": {
  371. "secretKeyRef" : {
  372. "name" : "${NAME}",
  373. "key" : "database-password"
  374. }
  375. }
  376. },
  377. {
  378. "name": "MYSQL_DATABASE",
  379. "value": "${DATABASE_NAME}"
  380. }
  381. ],
  382. "resources": {
  383. "limits": {
  384. "memory": "${MEMORY_MYSQL_LIMIT}"
  385. }
  386. }
  387. }
  388. ]
  389. }
  390. }
  391. }
  392. }
  393. ],
  394. "parameters": [
  395. {
  396. "name": "NAME",
  397. "displayName": "Name",
  398. "description": "The name assigned to all of the frontend objects defined in this template.",
  399. "required": true,
  400. "value": "dancer-mysql-example"
  401. },
  402. {
  403. "name": "NAMESPACE",
  404. "displayName": "Namespace",
  405. "description": "The OpenShift Namespace where the ImageStream resides.",
  406. "required": true,
  407. "value": "openshift"
  408. },
  409. {
  410. "name": "MEMORY_LIMIT",
  411. "displayName": "Memory Limit",
  412. "description": "Maximum amount of memory the Perl Dancer container can use.",
  413. "required": true,
  414. "value": "512Mi"
  415. },
  416. {
  417. "name": "MEMORY_MYSQL_LIMIT",
  418. "displayName": "Memory Limit (MySQL)",
  419. "description": "Maximum amount of memory the MySQL container can use.",
  420. "required": true,
  421. "value": "512Mi"
  422. },
  423. {
  424. "name": "SOURCE_REPOSITORY_URL",
  425. "displayName": "Git Repository URL",
  426. "description": "The URL of the repository with your application source code.",
  427. "required": true,
  428. "value": "https://github.com/openshift/dancer-ex.git"
  429. },
  430. {
  431. "name": "SOURCE_REPOSITORY_REF",
  432. "displayName": "Git Reference",
  433. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  434. },
  435. {
  436. "name": "CONTEXT_DIR",
  437. "displayName": "Context Directory",
  438. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  439. },
  440. {
  441. "name": "APPLICATION_DOMAIN",
  442. "displayName": "Application Hostname",
  443. "description": "The exposed hostname that will route to the Dancer service, if left blank a value will be defaulted.",
  444. "value": ""
  445. },
  446. {
  447. "name": "GITHUB_WEBHOOK_SECRET",
  448. "displayName": "GitHub Webhook Secret",
  449. "description": "A secret string used to configure the GitHub webhook.",
  450. "generate": "expression",
  451. "from": "[a-zA-Z0-9]{40}"
  452. },
  453. {
  454. "name": "DATABASE_SERVICE_NAME",
  455. "displayName": "Database Service Name",
  456. "required": true,
  457. "value": "database"
  458. },
  459. {
  460. "name": "DATABASE_USER",
  461. "displayName": "Database Username",
  462. "generate": "expression",
  463. "from": "user[A-Z0-9]{3}"
  464. },
  465. {
  466. "name": "DATABASE_PASSWORD",
  467. "displayName": "Database Password",
  468. "generate": "expression",
  469. "from": "[a-zA-Z0-9]{8}"
  470. },
  471. {
  472. "name": "DATABASE_NAME",
  473. "displayName": "Database Name",
  474. "required": true,
  475. "value": "sampledb"
  476. },
  477. {
  478. "name": "PERL_APACHE2_RELOAD",
  479. "displayName": "Perl Module Reload",
  480. "description": "Set this to \"true\" to enable automatic reloading of modified Perl modules.",
  481. "value": ""
  482. },
  483. {
  484. "name": "SECRET_KEY_BASE",
  485. "displayName": "Secret Key",
  486. "description": "Your secret key for verifying the integrity of signed cookies.",
  487. "generate": "expression",
  488. "from": "[a-z0-9]{127}"
  489. },
  490. {
  491. "name": "CPAN_MIRROR",
  492. "displayName": "Custom CPAN Mirror URL",
  493. "description": "The custom CPAN mirror URL",
  494. "value": ""
  495. }
  496. ]
  497. }