cakephp-mysql-persistent.json 17 KB

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