dancer-mysql.json 14 KB

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