mysql-persistent-template.json 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "mysql-persistent",
  6. "annotations": {
  7. "openshift.io/display-name": "MySQL (Persistent)",
  8. "description": "MySQL database service, with persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/mysql-container/blob/master/5.7/README.md.\n\nNOTE: 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. "message": "The following service(s) have been created in your project: ${DATABASE_SERVICE_NAME}.\n\n Username: ${MYSQL_USER}\n Password: ${MYSQL_PASSWORD}\n Database Name: ${MYSQL_DATABASE}\n Connection URL: mysql://${DATABASE_SERVICE_NAME}:3306/\n\nFor more information about using this template, including OpenShift considerations, see https://github.com/sclorg/mysql-container/blob/master/5.7/README.md.",
  14. "labels": {
  15. "template": "mysql-persistent-template"
  16. },
  17. "objects": [
  18. {
  19. "kind": "Secret",
  20. "apiVersion": "v1",
  21. "metadata": {
  22. "name": "${DATABASE_SERVICE_NAME}"
  23. },
  24. "stringData" : {
  25. "database-user" : "${MYSQL_USER}",
  26. "database-password" : "${MYSQL_PASSWORD}",
  27. "database-root-password" : "${MYSQL_ROOT_PASSWORD}"
  28. }
  29. },
  30. {
  31. "kind": "Service",
  32. "apiVersion": "v1",
  33. "metadata": {
  34. "name": "${DATABASE_SERVICE_NAME}"
  35. },
  36. "spec": {
  37. "ports": [
  38. {
  39. "name": "mysql",
  40. "port": 3306
  41. }
  42. ],
  43. "selector": {
  44. "name": "${DATABASE_SERVICE_NAME}"
  45. }
  46. }
  47. },
  48. {
  49. "kind": "PersistentVolumeClaim",
  50. "apiVersion": "v1",
  51. "metadata": {
  52. "name": "${DATABASE_SERVICE_NAME}"
  53. },
  54. "spec": {
  55. "accessModes": [
  56. "ReadWriteOnce"
  57. ],
  58. "resources": {
  59. "requests": {
  60. "storage": "${VOLUME_CAPACITY}"
  61. }
  62. }
  63. }
  64. },
  65. {
  66. "kind": "DeploymentConfig",
  67. "apiVersion": "v1",
  68. "metadata": {
  69. "name": "${DATABASE_SERVICE_NAME}"
  70. },
  71. "spec": {
  72. "strategy": {
  73. "type": "Recreate"
  74. },
  75. "triggers": [
  76. {
  77. "type": "ImageChange",
  78. "imageChangeParams": {
  79. "automatic": true,
  80. "containerNames": [
  81. "mysql"
  82. ],
  83. "from": {
  84. "kind": "ImageStreamTag",
  85. "name": "mysql:${MYSQL_VERSION}",
  86. "namespace": "${NAMESPACE}"
  87. }
  88. }
  89. },
  90. {
  91. "type": "ConfigChange"
  92. }
  93. ],
  94. "replicas": 1,
  95. "selector": {
  96. "name": "${DATABASE_SERVICE_NAME}"
  97. },
  98. "template": {
  99. "metadata": {
  100. "labels": {
  101. "name": "${DATABASE_SERVICE_NAME}"
  102. }
  103. },
  104. "spec": {
  105. "containers": [
  106. {
  107. "name": "mysql",
  108. "image": " ",
  109. "ports": [
  110. {
  111. "containerPort": 3306
  112. }
  113. ],
  114. "readinessProbe": {
  115. "timeoutSeconds": 1,
  116. "initialDelaySeconds": 5,
  117. "exec": {
  118. "command": [ "/bin/sh", "-i", "-c",
  119. "MYSQL_PWD=\"$MYSQL_PASSWORD\" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'"]
  120. }
  121. },
  122. "livenessProbe": {
  123. "timeoutSeconds": 1,
  124. "initialDelaySeconds": 30,
  125. "tcpSocket": {
  126. "port": 3306
  127. }
  128. },
  129. "env": [
  130. {
  131. "name": "MYSQL_USER",
  132. "valueFrom": {
  133. "secretKeyRef" : {
  134. "name" : "${DATABASE_SERVICE_NAME}",
  135. "key" : "database-user"
  136. }
  137. }
  138. },
  139. {
  140. "name": "MYSQL_PASSWORD",
  141. "valueFrom": {
  142. "secretKeyRef" : {
  143. "name" : "${DATABASE_SERVICE_NAME}",
  144. "key" : "database-password"
  145. }
  146. }
  147. },
  148. {
  149. "name": "MYSQL_ROOT_PASSWORD",
  150. "valueFrom": {
  151. "secretKeyRef" : {
  152. "name" : "${DATABASE_SERVICE_NAME}",
  153. "key" : "database-root-password"
  154. }
  155. }
  156. },
  157. {
  158. "name": "MYSQL_DATABASE",
  159. "value": "${MYSQL_DATABASE}"
  160. }
  161. ],
  162. "resources": {
  163. "limits": {
  164. "memory": "${MEMORY_LIMIT}"
  165. }
  166. },
  167. "volumeMounts": [
  168. {
  169. "name": "${DATABASE_SERVICE_NAME}-data",
  170. "mountPath": "/var/lib/mysql/data"
  171. }
  172. ],
  173. "imagePullPolicy": "IfNotPresent"
  174. }
  175. ],
  176. "volumes": [
  177. {
  178. "name": "${DATABASE_SERVICE_NAME}-data",
  179. "persistentVolumeClaim": {
  180. "claimName": "${DATABASE_SERVICE_NAME}"
  181. }
  182. }
  183. ]
  184. }
  185. }
  186. }
  187. }
  188. ],
  189. "parameters": [
  190. {
  191. "name": "MEMORY_LIMIT",
  192. "displayName": "Memory Limit",
  193. "description": "Maximum amount of memory the container can use.",
  194. "value": "512Mi",
  195. "required": true
  196. },
  197. {
  198. "name": "NAMESPACE",
  199. "displayName": "Namespace",
  200. "description": "The OpenShift Namespace where the ImageStream resides.",
  201. "value": "openshift"
  202. },
  203. {
  204. "name": "DATABASE_SERVICE_NAME",
  205. "displayName": "Database Service Name",
  206. "description": "The name of the OpenShift Service exposed for the database.",
  207. "value": "mysql",
  208. "required": true
  209. },
  210. {
  211. "name": "MYSQL_USER",
  212. "displayName": "MySQL Connection Username",
  213. "description": "Username for MySQL user that will be used for accessing the database.",
  214. "generate": "expression",
  215. "from": "user[A-Z0-9]{3}",
  216. "required": true
  217. },
  218. {
  219. "name": "MYSQL_PASSWORD",
  220. "displayName": "MySQL Connection Password",
  221. "description": "Password for the MySQL connection user.",
  222. "generate": "expression",
  223. "from": "[a-zA-Z0-9]{16}",
  224. "required": true
  225. },
  226. {
  227. "name": "MYSQL_ROOT_PASSWORD",
  228. "displayName": "MySQL root user Password",
  229. "description": "Password for the MySQL root user.",
  230. "generate": "expression",
  231. "from": "[a-zA-Z0-9]{16}",
  232. "required": true
  233. },
  234. {
  235. "name": "MYSQL_DATABASE",
  236. "displayName": "MySQL Database Name",
  237. "description": "Name of the MySQL database accessed.",
  238. "value": "sampledb",
  239. "required": true
  240. },
  241. {
  242. "name": "VOLUME_CAPACITY",
  243. "displayName": "Volume Capacity",
  244. "description": "Volume space available for data, e.g. 512Mi, 2Gi.",
  245. "value": "1Gi",
  246. "required": true
  247. },
  248. {
  249. "name": "MYSQL_VERSION",
  250. "displayName": "Version of MySQL Image",
  251. "description": "Version of MySQL image to be used (5.5, 5.6, 5.7, or latest).",
  252. "value": "5.7",
  253. "required": true
  254. }
  255. ]
  256. }