mysql-ephemeral-template.json 5.6 KB

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