cakephp-mysql-persistent.json 17 KB

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