mysql-persistent-template.json 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "mysql-persistent",
  6. "creationTimestamp": null,
  7. "annotations": {
  8. "description": "MySQL database service, with persistent storage. Scaling to more than one replica is not supported. You must have persistent volumes available in your cluster to use this template.",
  9. "iconClass": "icon-mysql-database",
  10. "tags": "database,mysql"
  11. }
  12. },
  13. "objects": [
  14. {
  15. "kind": "Service",
  16. "apiVersion": "v1",
  17. "metadata": {
  18. "name": "${DATABASE_SERVICE_NAME}",
  19. "creationTimestamp": null
  20. },
  21. "spec": {
  22. "ports": [
  23. {
  24. "name": "mysql",
  25. "protocol": "TCP",
  26. "port": 3306,
  27. "targetPort": 3306,
  28. "nodePort": 0
  29. }
  30. ],
  31. "selector": {
  32. "name": "${DATABASE_SERVICE_NAME}"
  33. },
  34. "portalIP": "",
  35. "type": "ClusterIP",
  36. "sessionAffinity": "None"
  37. },
  38. "status": {
  39. "loadBalancer": {}
  40. }
  41. },
  42. {
  43. "kind": "PersistentVolumeClaim",
  44. "apiVersion": "v1",
  45. "metadata": {
  46. "name": "${DATABASE_SERVICE_NAME}"
  47. },
  48. "spec": {
  49. "accessModes": [
  50. "ReadWriteOnce"
  51. ],
  52. "resources": {
  53. "requests": {
  54. "storage": "${VOLUME_CAPACITY}"
  55. }
  56. }
  57. }
  58. },
  59. {
  60. "kind": "DeploymentConfig",
  61. "apiVersion": "v1",
  62. "metadata": {
  63. "name": "${DATABASE_SERVICE_NAME}",
  64. "creationTimestamp": null
  65. },
  66. "spec": {
  67. "strategy": {
  68. "type": "Recreate"
  69. },
  70. "triggers": [
  71. {
  72. "type": "ImageChange",
  73. "imageChangeParams": {
  74. "automatic": true,
  75. "containerNames": [
  76. "mysql"
  77. ],
  78. "from": {
  79. "kind": "ImageStreamTag",
  80. "name": "mysql:latest",
  81. "namespace": "${NAMESPACE}"
  82. },
  83. "lastTriggeredImage": ""
  84. }
  85. },
  86. {
  87. "type": "ConfigChange"
  88. }
  89. ],
  90. "replicas": 1,
  91. "selector": {
  92. "name": "${DATABASE_SERVICE_NAME}"
  93. },
  94. "template": {
  95. "metadata": {
  96. "creationTimestamp": null,
  97. "labels": {
  98. "name": "${DATABASE_SERVICE_NAME}"
  99. }
  100. },
  101. "spec": {
  102. "containers": [
  103. {
  104. "name": "mysql",
  105. "image": "mysql",
  106. "ports": [
  107. {
  108. "containerPort": 3306,
  109. "protocol": "TCP"
  110. }
  111. ],
  112. "readinessProbe": {
  113. "timeoutSeconds": 1,
  114. "initialDelaySeconds": 5,
  115. "exec": {
  116. "command": [ "/bin/sh", "-i", "-c",
  117. "MYSQL_PWD=\"$MYSQL_PASSWORD\" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'"]
  118. }
  119. },
  120. "livenessProbe": {
  121. "timeoutSeconds": 1,
  122. "initialDelaySeconds": 30,
  123. "tcpSocket": {
  124. "port": 3306
  125. }
  126. },
  127. "env": [
  128. {
  129. "name": "MYSQL_USER",
  130. "value": "${MYSQL_USER}"
  131. },
  132. {
  133. "name": "MYSQL_PASSWORD",
  134. "value": "${MYSQL_PASSWORD}"
  135. },
  136. {
  137. "name": "MYSQL_DATABASE",
  138. "value": "${MYSQL_DATABASE}"
  139. }
  140. ],
  141. "resources": {
  142. "limits": {
  143. "memory": "${MEMORY_LIMIT}"
  144. }
  145. },
  146. "volumeMounts": [
  147. {
  148. "name": "${DATABASE_SERVICE_NAME}-data",
  149. "mountPath": "/var/lib/mysql/data"
  150. }
  151. ],
  152. "terminationMessagePath": "/dev/termination-log",
  153. "imagePullPolicy": "IfNotPresent",
  154. "capabilities": {},
  155. "securityContext": {
  156. "capabilities": {},
  157. "privileged": false
  158. }
  159. }
  160. ],
  161. "volumes": [
  162. {
  163. "name": "${DATABASE_SERVICE_NAME}-data",
  164. "persistentVolumeClaim": {
  165. "claimName": "${DATABASE_SERVICE_NAME}"
  166. }
  167. }
  168. ],
  169. "restartPolicy": "Always",
  170. "dnsPolicy": "ClusterFirst"
  171. }
  172. }
  173. },
  174. "status": {}
  175. }
  176. ],
  177. "parameters": [
  178. {
  179. "name": "MEMORY_LIMIT",
  180. "displayName": "Memory Limit",
  181. "description": "Maximum amount of memory the container can use.",
  182. "value": "512Mi"
  183. },
  184. {
  185. "name": "NAMESPACE",
  186. "displayName": "Namespace",
  187. "description": "The OpenShift Namespace where the ImageStream resides.",
  188. "value": "openshift"
  189. },
  190. {
  191. "name": "DATABASE_SERVICE_NAME",
  192. "displayName": "Database Service Name",
  193. "description": "The name of the OpenShift Service exposed for the database.",
  194. "value": "mysql",
  195. "required": true
  196. },
  197. {
  198. "name": "MYSQL_USER",
  199. "displayName": "MySQL User",
  200. "description": "Username for MySQL user that will be used for accessing the database.",
  201. "generate": "expression",
  202. "from": "user[A-Z0-9]{3}",
  203. "required": true
  204. },
  205. {
  206. "name": "MYSQL_PASSWORD",
  207. "displayName": "MySQL Password",
  208. "description": "Password for the MySQL user.",
  209. "generate": "expression",
  210. "from": "[a-zA-Z0-9]{16}",
  211. "required": true
  212. },
  213. {
  214. "name": "MYSQL_DATABASE",
  215. "displayName": "MySQL Database Name",
  216. "description": "Name of the MySQL database accessed.",
  217. "value": "sampledb",
  218. "required": true
  219. },
  220. {
  221. "name": "VOLUME_CAPACITY",
  222. "displayName": "Volume Capacity",
  223. "description": "Volume space available for data, e.g. 512Mi, 2Gi.",
  224. "value": "1Gi",
  225. "required": true
  226. }
  227. ],
  228. "labels": {
  229. "template": "mysql-persistent-template"
  230. }
  231. }