mysql-ephemeral-template.json 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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.7/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.7/README.md.",
  14. "labels": {
  15. "template": "mysql-ephemeral-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. "creationTimestamp": null
  36. },
  37. "spec": {
  38. "ports": [
  39. {
  40. "name": "mysql",
  41. "protocol": "TCP",
  42. "port": 3306,
  43. "targetPort": 3306,
  44. "nodePort": 0
  45. }
  46. ],
  47. "selector": {
  48. "name": "${DATABASE_SERVICE_NAME}"
  49. },
  50. "type": "ClusterIP",
  51. "sessionAffinity": "None"
  52. },
  53. "status": {
  54. "loadBalancer": {}
  55. }
  56. },
  57. {
  58. "kind": "DeploymentConfig",
  59. "apiVersion": "v1",
  60. "metadata": {
  61. "name": "${DATABASE_SERVICE_NAME}",
  62. "creationTimestamp": null
  63. },
  64. "spec": {
  65. "strategy": {
  66. "type": "Recreate"
  67. },
  68. "triggers": [
  69. {
  70. "type": "ImageChange",
  71. "imageChangeParams": {
  72. "automatic": true,
  73. "containerNames": [
  74. "mysql"
  75. ],
  76. "from": {
  77. "kind": "ImageStreamTag",
  78. "name": "mysql:${MYSQL_VERSION}",
  79. "namespace": "${NAMESPACE}"
  80. },
  81. "lastTriggeredImage": ""
  82. }
  83. },
  84. {
  85. "type": "ConfigChange"
  86. }
  87. ],
  88. "replicas": 1,
  89. "selector": {
  90. "name": "${DATABASE_SERVICE_NAME}"
  91. },
  92. "template": {
  93. "metadata": {
  94. "creationTimestamp": null,
  95. "labels": {
  96. "name": "${DATABASE_SERVICE_NAME}"
  97. }
  98. },
  99. "spec": {
  100. "containers": [
  101. {
  102. "name": "mysql",
  103. "image": " ",
  104. "ports": [
  105. {
  106. "containerPort": 3306,
  107. "protocol": "TCP"
  108. }
  109. ],
  110. "readinessProbe": {
  111. "timeoutSeconds": 1,
  112. "initialDelaySeconds": 5,
  113. "exec": {
  114. "command": [ "/bin/sh", "-i", "-c",
  115. "MYSQL_PWD=\"$MYSQL_PASSWORD\" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'"]
  116. }
  117. },
  118. "livenessProbe": {
  119. "timeoutSeconds": 1,
  120. "initialDelaySeconds": 30,
  121. "tcpSocket": {
  122. "port": 3306
  123. }
  124. },
  125. "env": [
  126. {
  127. "name": "MYSQL_USER",
  128. "valueFrom": {
  129. "secretKeyRef" : {
  130. "name" : "${DATABASE_SERVICE_NAME}",
  131. "key" : "database-user"
  132. }
  133. }
  134. },
  135. {
  136. "name": "MYSQL_PASSWORD",
  137. "valueFrom": {
  138. "secretKeyRef" : {
  139. "name" : "${DATABASE_SERVICE_NAME}",
  140. "key" : "database-password"
  141. }
  142. }
  143. },
  144. {
  145. "name": "MYSQL_ROOT_PASSWORD",
  146. "valueFrom": {
  147. "secretKeyRef" : {
  148. "name" : "${DATABASE_SERVICE_NAME}",
  149. "key" : "database-root-password"
  150. }
  151. }
  152. },
  153. {
  154. "name": "MYSQL_DATABASE",
  155. "value": "${MYSQL_DATABASE}"
  156. }
  157. ],
  158. "resources": {
  159. "limits": {
  160. "memory": "${MEMORY_LIMIT}"
  161. }
  162. },
  163. "volumeMounts": [
  164. {
  165. "name": "${DATABASE_SERVICE_NAME}-data",
  166. "mountPath": "/var/lib/mysql/data"
  167. }
  168. ],
  169. "terminationMessagePath": "/dev/termination-log",
  170. "imagePullPolicy": "IfNotPresent",
  171. "capabilities": {},
  172. "securityContext": {
  173. "capabilities": {},
  174. "privileged": false
  175. }
  176. }
  177. ],
  178. "volumes": [
  179. {
  180. "name": "${DATABASE_SERVICE_NAME}-data",
  181. "emptyDir": {
  182. "medium": ""
  183. }
  184. }
  185. ],
  186. "restartPolicy": "Always",
  187. "dnsPolicy": "ClusterFirst"
  188. }
  189. }
  190. },
  191. "status": {}
  192. }
  193. ],
  194. "parameters": [
  195. {
  196. "name": "MEMORY_LIMIT",
  197. "displayName": "Memory Limit",
  198. "description": "Maximum amount of memory the container can use.",
  199. "value": "512Mi"
  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": "MYSQL_VERSION",
  247. "displayName": "Version of MySQL Image",
  248. "description": "Version of MySQL image to be used (5.5, 5.6, 5.7, or latest).",
  249. "value": "5.7",
  250. "required": true
  251. }
  252. ]
  253. }