cakephp-mysql-persistent.json 16 KB

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