mysql-persistent-template.json 8.2 KB

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