mysql-ephemeral-template.json 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "mysql-ephemeral",
  6. "annotations": {
  7. "openshift.io/display-name": "MySQL (Ephemeral)",
  8. "description": "MySQL database service, without persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/mysql-container/blob/master/5.6/README.md.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing",
  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.6/README.md.",
  14. "labels": {
  15. "template": "mysql-ephemeral-template"
  16. },
  17. "objects": [
  18. {
  19. "kind": "Service",
  20. "apiVersion": "v1",
  21. "metadata": {
  22. "name": "${DATABASE_SERVICE_NAME}",
  23. "creationTimestamp": null
  24. },
  25. "spec": {
  26. "ports": [
  27. {
  28. "name": "mysql",
  29. "protocol": "TCP",
  30. "port": 3306,
  31. "targetPort": 3306,
  32. "nodePort": 0
  33. }
  34. ],
  35. "selector": {
  36. "name": "${DATABASE_SERVICE_NAME}"
  37. },
  38. "type": "ClusterIP",
  39. "sessionAffinity": "None"
  40. },
  41. "status": {
  42. "loadBalancer": {}
  43. }
  44. },
  45. {
  46. "kind": "DeploymentConfig",
  47. "apiVersion": "v1",
  48. "metadata": {
  49. "name": "${DATABASE_SERVICE_NAME}",
  50. "creationTimestamp": null
  51. },
  52. "spec": {
  53. "strategy": {
  54. "type": "Recreate"
  55. },
  56. "triggers": [
  57. {
  58. "type": "ImageChange",
  59. "imageChangeParams": {
  60. "automatic": true,
  61. "containerNames": [
  62. "mysql"
  63. ],
  64. "from": {
  65. "kind": "ImageStreamTag",
  66. "name": "mysql:${MYSQL_VERSION}",
  67. "namespace": "${NAMESPACE}"
  68. },
  69. "lastTriggeredImage": ""
  70. }
  71. },
  72. {
  73. "type": "ConfigChange"
  74. }
  75. ],
  76. "replicas": 1,
  77. "selector": {
  78. "name": "${DATABASE_SERVICE_NAME}"
  79. },
  80. "template": {
  81. "metadata": {
  82. "creationTimestamp": null,
  83. "labels": {
  84. "name": "${DATABASE_SERVICE_NAME}"
  85. }
  86. },
  87. "spec": {
  88. "containers": [
  89. {
  90. "name": "mysql",
  91. "image": " ",
  92. "ports": [
  93. {
  94. "containerPort": 3306,
  95. "protocol": "TCP"
  96. }
  97. ],
  98. "readinessProbe": {
  99. "timeoutSeconds": 1,
  100. "initialDelaySeconds": 5,
  101. "exec": {
  102. "command": [ "/bin/sh", "-i", "-c",
  103. "MYSQL_PWD=\"$MYSQL_PASSWORD\" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'"]
  104. }
  105. },
  106. "livenessProbe": {
  107. "timeoutSeconds": 1,
  108. "initialDelaySeconds": 30,
  109. "tcpSocket": {
  110. "port": 3306
  111. }
  112. },
  113. "env": [
  114. {
  115. "name": "MYSQL_USER",
  116. "value": "${MYSQL_USER}"
  117. },
  118. {
  119. "name": "MYSQL_PASSWORD",
  120. "value": "${MYSQL_PASSWORD}"
  121. },
  122. {
  123. "name": "MYSQL_DATABASE",
  124. "value": "${MYSQL_DATABASE}"
  125. }
  126. ],
  127. "resources": {
  128. "limits": {
  129. "memory": "${MEMORY_LIMIT}"
  130. }
  131. },
  132. "volumeMounts": [
  133. {
  134. "name": "${DATABASE_SERVICE_NAME}-data",
  135. "mountPath": "/var/lib/mysql/data"
  136. }
  137. ],
  138. "terminationMessagePath": "/dev/termination-log",
  139. "imagePullPolicy": "IfNotPresent",
  140. "capabilities": {},
  141. "securityContext": {
  142. "capabilities": {},
  143. "privileged": false
  144. }
  145. }
  146. ],
  147. "volumes": [
  148. {
  149. "name": "${DATABASE_SERVICE_NAME}-data",
  150. "emptyDir": {
  151. "medium": ""
  152. }
  153. }
  154. ],
  155. "restartPolicy": "Always",
  156. "dnsPolicy": "ClusterFirst"
  157. }
  158. }
  159. },
  160. "status": {}
  161. }
  162. ],
  163. "parameters": [
  164. {
  165. "name": "MEMORY_LIMIT",
  166. "displayName": "Memory Limit",
  167. "description": "Maximum amount of memory the container can use.",
  168. "value": "512Mi"
  169. },
  170. {
  171. "name": "NAMESPACE",
  172. "displayName": "Namespace",
  173. "description": "The OpenShift Namespace where the ImageStream resides.",
  174. "value": "openshift"
  175. },
  176. {
  177. "name": "DATABASE_SERVICE_NAME",
  178. "displayName": "Database Service Name",
  179. "description": "The name of the OpenShift Service exposed for the database.",
  180. "value": "mysql",
  181. "required": true
  182. },
  183. {
  184. "name": "MYSQL_USER",
  185. "displayName": "MySQL Connection Username",
  186. "description": "Username for MySQL user that will be used for accessing the database.",
  187. "generate": "expression",
  188. "from": "user[A-Z0-9]{3}",
  189. "required": true
  190. },
  191. {
  192. "name": "MYSQL_PASSWORD",
  193. "displayName": "MySQL Connection Password",
  194. "description": "Password for the MySQL connection user.",
  195. "generate": "expression",
  196. "from": "[a-zA-Z0-9]{16}",
  197. "required": true
  198. },
  199. {
  200. "name": "MYSQL_DATABASE",
  201. "displayName": "MySQL Database Name",
  202. "description": "Name of the MySQL database accessed.",
  203. "value": "sampledb",
  204. "required": true
  205. },
  206. {
  207. "name": "MYSQL_VERSION",
  208. "displayName": "Version of MySQL Image",
  209. "description": "Version of MySQL image to be used (5.5, 5.6 or latest).",
  210. "value": "5.6",
  211. "required": true
  212. }
  213. ]
  214. }