cakephp-mysql-persistent.json 17 KB

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