mysql-ephemeral-template.json 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "mysql-ephemeral",
  6. "creationTimestamp": null,
  7. "annotations": {
  8. "description": "MySQL database service, without persistent storage. WARNING: 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. "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": "DeploymentConfig",
  44. "apiVersion": "v1",
  45. "metadata": {
  46. "name": "${DATABASE_SERVICE_NAME}",
  47. "creationTimestamp": null
  48. },
  49. "spec": {
  50. "strategy": {
  51. "type": "Recreate"
  52. },
  53. "triggers": [
  54. {
  55. "type": "ImageChange",
  56. "imageChangeParams": {
  57. "automatic": false,
  58. "containerNames": [
  59. "mysql"
  60. ],
  61. "from": {
  62. "kind": "ImageStreamTag",
  63. "name": "mysql:latest",
  64. "namespace": "${NAMESPACE}"
  65. },
  66. "lastTriggeredImage": ""
  67. }
  68. },
  69. {
  70. "type": "ConfigChange"
  71. }
  72. ],
  73. "replicas": 1,
  74. "selector": {
  75. "name": "${DATABASE_SERVICE_NAME}"
  76. },
  77. "template": {
  78. "metadata": {
  79. "creationTimestamp": null,
  80. "labels": {
  81. "name": "${DATABASE_SERVICE_NAME}"
  82. }
  83. },
  84. "spec": {
  85. "containers": [
  86. {
  87. "name": "mysql",
  88. "image": "mysql",
  89. "ports": [
  90. {
  91. "containerPort": 3306,
  92. "protocol": "TCP"
  93. }
  94. ],
  95. "readinessProbe": {
  96. "timeoutSeconds": 1,
  97. "initialDelaySeconds": 5,
  98. "exec": {
  99. "command": [ "/bin/sh", "-i", "-c",
  100. "MYSQL_PWD=\"$MYSQL_PASSWORD\" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'"]
  101. }
  102. },
  103. "livenessProbe": {
  104. "timeoutSeconds": 1,
  105. "initialDelaySeconds": 30,
  106. "tcpSocket": {
  107. "port": 3306
  108. }
  109. },
  110. "env": [
  111. {
  112. "name": "MYSQL_USER",
  113. "value": "${MYSQL_USER}"
  114. },
  115. {
  116. "name": "MYSQL_PASSWORD",
  117. "value": "${MYSQL_PASSWORD}"
  118. },
  119. {
  120. "name": "MYSQL_DATABASE",
  121. "value": "${MYSQL_DATABASE}"
  122. }
  123. ],
  124. "resources": {
  125. "limits": {
  126. "memory": "${MEMORY_LIMIT}"
  127. }
  128. },
  129. "volumeMounts": [
  130. {
  131. "name": "${DATABASE_SERVICE_NAME}-data",
  132. "mountPath": "/var/lib/mysql/data"
  133. }
  134. ],
  135. "terminationMessagePath": "/dev/termination-log",
  136. "imagePullPolicy": "IfNotPresent",
  137. "capabilities": {},
  138. "securityContext": {
  139. "capabilities": {},
  140. "privileged": false
  141. }
  142. }
  143. ],
  144. "volumes": [
  145. {
  146. "name": "${DATABASE_SERVICE_NAME}-data",
  147. "emptyDir": {
  148. "medium": ""
  149. }
  150. }
  151. ],
  152. "restartPolicy": "Always",
  153. "dnsPolicy": "ClusterFirst"
  154. }
  155. }
  156. },
  157. "status": {}
  158. }
  159. ],
  160. "parameters": [
  161. {
  162. "name": "MEMORY_LIMIT",
  163. "displayName": "Memory Limit",
  164. "description": "Maximum amount of memory the container can use.",
  165. "value": "512Mi"
  166. },
  167. {
  168. "name": "NAMESPACE",
  169. "displayName": "Namespace",
  170. "description": "The OpenShift Namespace where the ImageStream resides.",
  171. "value": "openshift"
  172. },
  173. {
  174. "name": "DATABASE_SERVICE_NAME",
  175. "displayName": "Database Service Name",
  176. "description": "The name of the OpenShift Service exposed for the database.",
  177. "value": "mysql",
  178. "required": true
  179. },
  180. {
  181. "name": "MYSQL_USER",
  182. "displayName": "MySQL User",
  183. "description": "Username for MySQL user that will be used for accessing the database.",
  184. "generate": "expression",
  185. "from": "user[A-Z0-9]{3}",
  186. "required": true
  187. },
  188. {
  189. "name": "MYSQL_PASSWORD",
  190. "displayName": "MySQL Password",
  191. "description": "Password for the MySQL user.",
  192. "generate": "expression",
  193. "from": "[a-zA-Z0-9]{16}",
  194. "required": true
  195. },
  196. {
  197. "name": "MYSQL_DATABASE",
  198. "displayName": "MySQL Database Name",
  199. "description": "Name of the MySQL database accessed.",
  200. "value": "sampledb",
  201. "required": true
  202. }
  203. ],
  204. "labels": {
  205. "template": "mysql-ephemeral-template"
  206. }
  207. }