dancer-mysql.json 14 KB

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