dancer-mysql.json 13 KB

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