cakephp-mysql-persistent.json 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "cakephp-mysql-persistent",
  6. "annotations": {
  7. "openshift.io/display-name": "CakePHP + MySQL",
  8. "description": "An example CakePHP application with a MySQL database. For more information about using this template, including OpenShift considerations, see https://github.com/openshift/cakephp-ex/blob/master/README.md.",
  9. "tags": "quickstart,php,cakephp",
  10. "iconClass": "icon-php",
  11. "openshift.io/long-description": "This template defines resources needed to develop a CakePHP application, including a build configuration, application deployment configuration, and database deployment configuration.",
  12. "openshift.io/provider-display-name": "Red Hat, Inc.",
  13. "openshift.io/documentation-url": "https://github.com/openshift/cakephp-ex",
  14. "openshift.io/support-url": "https://access.redhat.com",
  15. "template.openshift.io/bindable": "false"
  16. }
  17. },
  18. "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/cake-ex/blob/master/README.md.",
  19. "labels": {
  20. "template": "cakephp-mysql-persistent",
  21. "app": "cakephp-mysql-persistent"
  22. },
  23. "objects": [
  24. {
  25. "kind": "Secret",
  26. "apiVersion": "v1",
  27. "metadata": {
  28. "name": "${NAME}"
  29. },
  30. "stringData" : {
  31. "database-user" : "${DATABASE_USER}",
  32. "database-password" : "${DATABASE_PASSWORD}",
  33. "cakephp-secret-token" : "${CAKEPHP_SECRET_TOKEN}",
  34. "cakephp-security-salt" : "${CAKEPHP_SECURITY_SALT}",
  35. "cakephp-security-cipher-seed" : "${CAKEPHP_SECURITY_CIPHER_SEED}"
  36. }
  37. },
  38. {
  39. "kind": "Service",
  40. "apiVersion": "v1",
  41. "metadata": {
  42. "name": "${NAME}",
  43. "annotations": {
  44. "description": "Exposes and load balances the application pods",
  45. "service.alpha.openshift.io/dependencies": "[{\"name\": \"${DATABASE_SERVICE_NAME}\", \"kind\": \"Service\"}]"
  46. }
  47. },
  48. "spec": {
  49. "ports": [
  50. {
  51. "name": "web",
  52. "port": 8080,
  53. "targetPort": 8080
  54. }
  55. ],
  56. "selector": {
  57. "name": "${NAME}"
  58. }
  59. }
  60. },
  61. {
  62. "kind": "Route",
  63. "apiVersion": "v1",
  64. "metadata": {
  65. "name": "${NAME}"
  66. },
  67. "spec": {
  68. "host": "${APPLICATION_DOMAIN}",
  69. "to": {
  70. "kind": "Service",
  71. "name": "${NAME}"
  72. }
  73. }
  74. },
  75. {
  76. "kind": "ImageStream",
  77. "apiVersion": "v1",
  78. "metadata": {
  79. "name": "${NAME}",
  80. "annotations": {
  81. "description": "Keeps track of changes in the application image"
  82. }
  83. }
  84. },
  85. {
  86. "kind": "BuildConfig",
  87. "apiVersion": "v1",
  88. "metadata": {
  89. "name": "${NAME}",
  90. "annotations": {
  91. "description": "Defines how to build the application",
  92. "template.alpha.openshift.io/wait-for-ready": "true"
  93. }
  94. },
  95. "spec": {
  96. "source": {
  97. "type": "Git",
  98. "git": {
  99. "uri": "${SOURCE_REPOSITORY_URL}",
  100. "ref": "${SOURCE_REPOSITORY_REF}"
  101. },
  102. "contextDir": "${CONTEXT_DIR}"
  103. },
  104. "strategy": {
  105. "type": "Source",
  106. "sourceStrategy": {
  107. "from": {
  108. "kind": "ImageStreamTag",
  109. "namespace": "${NAMESPACE}",
  110. "name": "php:7.0"
  111. },
  112. "env": [
  113. {
  114. "name": "COMPOSER_MIRROR",
  115. "value": "${COMPOSER_MIRROR}"
  116. }
  117. ]
  118. }
  119. },
  120. "output": {
  121. "to": {
  122. "kind": "ImageStreamTag",
  123. "name": "${NAME}:latest"
  124. }
  125. },
  126. "triggers": [
  127. {
  128. "type": "ImageChange"
  129. },
  130. {
  131. "type": "ConfigChange"
  132. },
  133. {
  134. "type": "GitHub",
  135. "github": {
  136. "secret": "${GITHUB_WEBHOOK_SECRET}"
  137. }
  138. }
  139. ],
  140. "postCommit": {
  141. "script": "./lib/Cake/Console/cake test app AllTests"
  142. }
  143. }
  144. },
  145. {
  146. "kind": "DeploymentConfig",
  147. "apiVersion": "v1",
  148. "metadata": {
  149. "name": "${NAME}",
  150. "annotations": {
  151. "description": "Defines how to deploy the application server",
  152. "template.alpha.openshift.io/wait-for-ready": "true"
  153. }
  154. },
  155. "spec": {
  156. "strategy": {
  157. "type": "Recreate",
  158. "recreateParams": {
  159. "pre": {
  160. "failurePolicy": "Retry",
  161. "execNewPod": {
  162. "command": [
  163. "./migrate-database.sh"
  164. ],
  165. "containerName": "cakephp-mysql-persistent"
  166. }
  167. }
  168. }
  169. },
  170. "triggers": [
  171. {
  172. "type": "ImageChange",
  173. "imageChangeParams": {
  174. "automatic": true,
  175. "containerNames": [
  176. "cakephp-mysql-persistent"
  177. ],
  178. "from": {
  179. "kind": "ImageStreamTag",
  180. "name": "${NAME}:latest"
  181. }
  182. }
  183. },
  184. {
  185. "type": "ConfigChange"
  186. }
  187. ],
  188. "replicas": 1,
  189. "selector": {
  190. "name": "${NAME}"
  191. },
  192. "template": {
  193. "metadata": {
  194. "name": "${NAME}",
  195. "labels": {
  196. "name": "${NAME}"
  197. }
  198. },
  199. "spec": {
  200. "containers": [
  201. {
  202. "name": "cakephp-mysql-persistent",
  203. "image": " ",
  204. "ports": [
  205. {
  206. "containerPort": 8080
  207. }
  208. ],
  209. "readinessProbe": {
  210. "timeoutSeconds": 3,
  211. "initialDelaySeconds": 3,
  212. "httpGet": {
  213. "path": "/health.php",
  214. "port": 8080
  215. }
  216. },
  217. "livenessProbe": {
  218. "timeoutSeconds": 3,
  219. "initialDelaySeconds": 30,
  220. "httpGet": {
  221. "path": "/health.php",
  222. "port": 8080
  223. }
  224. },
  225. "env": [
  226. {
  227. "name": "DATABASE_SERVICE_NAME",
  228. "value": "${DATABASE_SERVICE_NAME}"
  229. },
  230. {
  231. "name": "DATABASE_ENGINE",
  232. "value": "${DATABASE_ENGINE}"
  233. },
  234. {
  235. "name": "DATABASE_NAME",
  236. "value": "${DATABASE_NAME}"
  237. },
  238. {
  239. "name": "DATABASE_USER",
  240. "valueFrom": {
  241. "secretKeyRef" : {
  242. "name" : "${NAME}",
  243. "key" : "database-user"
  244. }
  245. }
  246. },
  247. {
  248. "name": "DATABASE_PASSWORD",
  249. "valueFrom": {
  250. "secretKeyRef" : {
  251. "name" : "${NAME}",
  252. "key" : "database-password"
  253. }
  254. }
  255. },
  256. {
  257. "name": "CAKEPHP_SECRET_TOKEN",
  258. "valueFrom": {
  259. "secretKeyRef" : {
  260. "name" : "${NAME}",
  261. "key" : "cakephp-secret-token"
  262. }
  263. }
  264. },
  265. {
  266. "name": "CAKEPHP_SECURITY_SALT",
  267. "valueFrom": {
  268. "secretKeyRef" : {
  269. "name" : "${NAME}",
  270. "key" : "cakephp-security-salt"
  271. }
  272. }
  273. },
  274. {
  275. "name": "CAKEPHP_SECURITY_CIPHER_SEED",
  276. "valueFrom": {
  277. "secretKeyRef" : {
  278. "name" : "${NAME}",
  279. "key" : "cakephp-security-cipher-seed"
  280. }
  281. }
  282. },
  283. {
  284. "name": "OPCACHE_REVALIDATE_FREQ",
  285. "value": "${OPCACHE_REVALIDATE_FREQ}"
  286. }
  287. ],
  288. "resources": {
  289. "limits": {
  290. "memory": "${MEMORY_LIMIT}"
  291. }
  292. }
  293. }
  294. ]
  295. }
  296. }
  297. }
  298. },
  299. {
  300. "kind": "PersistentVolumeClaim",
  301. "apiVersion": "v1",
  302. "metadata": {
  303. "name": "${DATABASE_SERVICE_NAME}"
  304. },
  305. "spec": {
  306. "accessModes": [
  307. "ReadWriteOnce"
  308. ],
  309. "resources": {
  310. "requests": {
  311. "storage": "${VOLUME_CAPACITY}"
  312. }
  313. }
  314. }
  315. },
  316. {
  317. "kind": "Service",
  318. "apiVersion": "v1",
  319. "metadata": {
  320. "name": "${DATABASE_SERVICE_NAME}",
  321. "annotations": {
  322. "description": "Exposes the database server"
  323. }
  324. },
  325. "spec": {
  326. "ports": [
  327. {
  328. "name": "mysql",
  329. "port": 3306,
  330. "targetPort": 3306
  331. }
  332. ],
  333. "selector": {
  334. "name": "${DATABASE_SERVICE_NAME}"
  335. }
  336. }
  337. },
  338. {
  339. "kind": "DeploymentConfig",
  340. "apiVersion": "v1",
  341. "metadata": {
  342. "name": "${DATABASE_SERVICE_NAME}",
  343. "annotations": {
  344. "description": "Defines how to deploy the database",
  345. "template.alpha.openshift.io/wait-for-ready": "true"
  346. }
  347. },
  348. "spec": {
  349. "strategy": {
  350. "type": "Recreate"
  351. },
  352. "triggers": [
  353. {
  354. "type": "ImageChange",
  355. "imageChangeParams": {
  356. "automatic": true,
  357. "containerNames": [
  358. "mysql"
  359. ],
  360. "from": {
  361. "kind": "ImageStreamTag",
  362. "namespace": "${NAMESPACE}",
  363. "name": "mysql:5.7"
  364. }
  365. }
  366. },
  367. {
  368. "type": "ConfigChange"
  369. }
  370. ],
  371. "replicas": 1,
  372. "selector": {
  373. "name": "${DATABASE_SERVICE_NAME}"
  374. },
  375. "template": {
  376. "metadata": {
  377. "name": "${DATABASE_SERVICE_NAME}",
  378. "labels": {
  379. "name": "${DATABASE_SERVICE_NAME}"
  380. }
  381. },
  382. "spec": {
  383. "volumes": [
  384. {
  385. "name": "${DATABASE_SERVICE_NAME}-data",
  386. "persistentVolumeClaim": {
  387. "claimName": "${DATABASE_SERVICE_NAME}"
  388. }
  389. }
  390. ],
  391. "containers": [
  392. {
  393. "name": "mysql",
  394. "image": " ",
  395. "ports": [
  396. {
  397. "containerPort": 3306
  398. }
  399. ],
  400. "volumeMounts": [
  401. {
  402. "name": "${DATABASE_SERVICE_NAME}-data",
  403. "mountPath": "/var/lib/mysql/data"
  404. }
  405. ],
  406. "readinessProbe": {
  407. "timeoutSeconds": 1,
  408. "initialDelaySeconds": 5,
  409. "exec": {
  410. "command": [ "/bin/sh", "-i", "-c", "MYSQL_PWD='${DATABASE_PASSWORD}' mysql -h 127.0.0.1 -u ${DATABASE_USER} -D ${DATABASE_NAME} -e 'SELECT 1'" ]
  411. }
  412. },
  413. "livenessProbe": {
  414. "timeoutSeconds": 1,
  415. "initialDelaySeconds": 30,
  416. "tcpSocket": {
  417. "port": 3306
  418. }
  419. },
  420. "env": [
  421. {
  422. "name": "MYSQL_USER",
  423. "valueFrom": {
  424. "secretKeyRef" : {
  425. "name" : "${NAME}",
  426. "key" : "database-user"
  427. }
  428. }
  429. },
  430. {
  431. "name": "MYSQL_PASSWORD",
  432. "valueFrom": {
  433. "secretKeyRef" : {
  434. "name" : "${NAME}",
  435. "key" : "database-password"
  436. }
  437. }
  438. },
  439. {
  440. "name": "MYSQL_DATABASE",
  441. "value": "${DATABASE_NAME}"
  442. }
  443. ],
  444. "resources": {
  445. "limits": {
  446. "memory": "${MEMORY_MYSQL_LIMIT}"
  447. }
  448. }
  449. }
  450. ]
  451. }
  452. }
  453. }
  454. }
  455. ],
  456. "parameters": [
  457. {
  458. "name": "NAME",
  459. "displayName": "Name",
  460. "description": "The name assigned to all of the frontend objects defined in this template.",
  461. "required": true,
  462. "value": "cakephp-mysql-persistent"
  463. },
  464. {
  465. "name": "NAMESPACE",
  466. "displayName": "Namespace",
  467. "description": "The OpenShift Namespace where the ImageStream resides.",
  468. "required": true,
  469. "value": "openshift"
  470. },
  471. {
  472. "name": "MEMORY_LIMIT",
  473. "displayName": "Memory Limit",
  474. "description": "Maximum amount of memory the CakePHP container can use.",
  475. "required": true,
  476. "value": "512Mi"
  477. },
  478. {
  479. "name": "MEMORY_MYSQL_LIMIT",
  480. "displayName": "Memory Limit (MySQL)",
  481. "description": "Maximum amount of memory the MySQL container can use.",
  482. "required": true,
  483. "value": "512Mi"
  484. },
  485. {
  486. "name": "VOLUME_CAPACITY",
  487. "displayName": "Volume Capacity",
  488. "description": "Volume space available for data, e.g. 512Mi, 2Gi",
  489. "value": "1Gi",
  490. "required": true
  491. },
  492. {
  493. "name": "SOURCE_REPOSITORY_URL",
  494. "displayName": "Git Repository URL",
  495. "description": "The URL of the repository with your application source code.",
  496. "required": true,
  497. "value": "https://github.com/openshift/cakephp-ex.git"
  498. },
  499. {
  500. "name": "SOURCE_REPOSITORY_REF",
  501. "displayName": "Git Reference",
  502. "description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
  503. },
  504. {
  505. "name": "CONTEXT_DIR",
  506. "displayName": "Context Directory",
  507. "description": "Set this to the relative path to your project if it is not in the root of your repository."
  508. },
  509. {
  510. "name": "APPLICATION_DOMAIN",
  511. "displayName": "Application Hostname",
  512. "description": "The exposed hostname that will route to the CakePHP service, if left blank a value will be defaulted.",
  513. "value": ""
  514. },
  515. {
  516. "name": "GITHUB_WEBHOOK_SECRET",
  517. "displayName": "GitHub Webhook Secret",
  518. "description": "Github trigger secret. A difficult to guess string encoded as part of the webhook URL. Not encrypted.",
  519. "generate": "expression",
  520. "from": "[a-zA-Z0-9]{40}"
  521. },
  522. {
  523. "name": "DATABASE_SERVICE_NAME",
  524. "displayName": "Database Service Name",
  525. "required": true,
  526. "value": "mysql"
  527. },
  528. {
  529. "name": "DATABASE_ENGINE",
  530. "displayName": "Database Engine",
  531. "description": "Database engine: postgresql, mysql or sqlite (default).",
  532. "required": true,
  533. "value": "mysql"
  534. },
  535. {
  536. "name": "DATABASE_NAME",
  537. "displayName": "Database Name",
  538. "required": true,
  539. "value": "default"
  540. },
  541. {
  542. "name": "DATABASE_USER",
  543. "displayName": "Database User",
  544. "required": true,
  545. "value": "cakephp"
  546. },
  547. {
  548. "name": "DATABASE_PASSWORD",
  549. "displayName": "Database Password",
  550. "generate": "expression",
  551. "from": "[a-zA-Z0-9]{16}"
  552. },
  553. {
  554. "name": "CAKEPHP_SECRET_TOKEN",
  555. "displayName": "CakePHP secret token",
  556. "description": "Set this to a long random string.",
  557. "generate": "expression",
  558. "from": "[\\w]{50}"
  559. },
  560. {
  561. "name": "CAKEPHP_SECURITY_SALT",
  562. "displayName": "CakePHP Security Salt",
  563. "description": "Security salt for session hash.",
  564. "generate": "expression",
  565. "from": "[a-zA-Z0-9]{40}"
  566. },
  567. {
  568. "name": "CAKEPHP_SECURITY_CIPHER_SEED",
  569. "displayName": "CakePHP Security Cipher Seed",
  570. "description": "Security cipher seed for session hash.",
  571. "generate": "expression",
  572. "from": "[0-9]{30}"
  573. },
  574. {
  575. "name": "OPCACHE_REVALIDATE_FREQ",
  576. "displayName": "OPcache Revalidation Frequency",
  577. "description": "How often to check script timestamps for updates, in seconds. 0 will result in OPcache checking for updates on every request.",
  578. "value": "2"
  579. },
  580. {
  581. "name": "COMPOSER_MIRROR",
  582. "displayName": "Custom Composer Mirror URL",
  583. "description": "The custom Composer mirror URL",
  584. "value": ""
  585. }
  586. ]
  587. }