mariadb-ephemeral-template.json 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "mariadb-ephemeral",
  6. "annotations": {
  7. "openshift.io/display-name": "MariaDB (Ephemeral)",
  8. "description": "MariaDB database service, without persistent storage. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/mariadb-container/blob/master/10.1/README.md.\n\nWARNING: Any data stored will be lost upon pod destruction. Only use this template for testing",
  9. "iconClass": "icon-mariadb",
  10. "tags": "database,mariadb",
  11. "template.openshift.io/long-description": "This template provides a standalone MariaDB server with a database created. The database is not stored on persistent storage, so any restart of the service will result in all data being lost. 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://github.com/sclorg/mariadb-container/blob/master/10.1/README.md",
  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/mariadb-container/blob/master/10.1/README.md.",
  18. "labels": {
  19. "template": "mariadb-persistent-template"
  20. },
  21. "objects": [
  22. {
  23. "kind": "Secret",
  24. "apiVersion": "v1",
  25. "metadata": {
  26. "name": "${DATABASE_SERVICE_NAME}",
  27. "annotations": {
  28. "template.openshift.io/expose-username": "{.data['database-user']}",
  29. "template.openshift.io/expose-password": "{.data['database-password']}",
  30. "template.openshift.io/expose-root_password": "{.data['database-root-password']}"
  31. }
  32. },
  33. "stringData" : {
  34. "database-user" : "${MYSQL_USER}",
  35. "database-password" : "${MYSQL_PASSWORD}",
  36. "database-root-password" : "${MYSQL_ROOT_PASSWORD}"
  37. }
  38. },
  39. {
  40. "kind": "Service",
  41. "apiVersion": "v1",
  42. "metadata": {
  43. "name": "${DATABASE_SERVICE_NAME}",
  44. "annotations": {
  45. "template.openshift.io/expose-uri": "mysql://{.spec.clusterIP}:{.spec.ports[?(.name==\"mariadb\")].port}"
  46. }
  47. },
  48. "spec": {
  49. "ports": [
  50. {
  51. "name": "mariadb",
  52. "port": 3306
  53. }
  54. ],
  55. "selector": {
  56. "name": "${DATABASE_SERVICE_NAME}"
  57. }
  58. }
  59. },
  60. {
  61. "kind": "DeploymentConfig",
  62. "apiVersion": "v1",
  63. "metadata": {
  64. "name": "${DATABASE_SERVICE_NAME}"
  65. },
  66. "spec": {
  67. "strategy": {
  68. "type": "Recreate"
  69. },
  70. "triggers": [
  71. {
  72. "type": "ImageChange",
  73. "imageChangeParams": {
  74. "automatic": true,
  75. "containerNames": [
  76. "mariadb"
  77. ],
  78. "from": {
  79. "kind": "ImageStreamTag",
  80. "name": "mariadb:10.1",
  81. "namespace": "${NAMESPACE}"
  82. }
  83. }
  84. },
  85. {
  86. "type": "ConfigChange"
  87. }
  88. ],
  89. "replicas": 1,
  90. "selector": {
  91. "name": "${DATABASE_SERVICE_NAME}"
  92. },
  93. "template": {
  94. "metadata": {
  95. "labels": {
  96. "name": "${DATABASE_SERVICE_NAME}"
  97. }
  98. },
  99. "spec": {
  100. "containers": [
  101. {
  102. "name": "mariadb",
  103. "image": " ",
  104. "ports": [
  105. {
  106. "containerPort": 3306
  107. }
  108. ],
  109. "readinessProbe": {
  110. "timeoutSeconds": 1,
  111. "initialDelaySeconds": 5,
  112. "exec": {
  113. "command": [ "/bin/sh", "-i", "-c",
  114. "MYSQL_PWD=\"$MYSQL_PASSWORD\" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'"]
  115. }
  116. },
  117. "livenessProbe": {
  118. "timeoutSeconds": 1,
  119. "initialDelaySeconds": 30,
  120. "tcpSocket": {
  121. "port": 3306
  122. }
  123. },
  124. "env": [
  125. {
  126. "name": "MYSQL_USER",
  127. "valueFrom": {
  128. "secretKeyRef" : {
  129. "name" : "${DATABASE_SERVICE_NAME}",
  130. "key" : "database-user"
  131. }
  132. }
  133. },
  134. {
  135. "name": "MYSQL_PASSWORD",
  136. "valueFrom": {
  137. "secretKeyRef" : {
  138. "name" : "${DATABASE_SERVICE_NAME}",
  139. "key" : "database-password"
  140. }
  141. }
  142. },
  143. {
  144. "name": "MYSQL_ROOT_PASSWORD",
  145. "valueFrom": {
  146. "secretKeyRef" : {
  147. "name" : "${DATABASE_SERVICE_NAME}",
  148. "key" : "database-root-password"
  149. }
  150. }
  151. },
  152. {
  153. "name": "MYSQL_DATABASE",
  154. "value": "${MYSQL_DATABASE}"
  155. }
  156. ],
  157. "resources": {
  158. "limits": {
  159. "memory": "${MEMORY_LIMIT}"
  160. }
  161. },
  162. "volumeMounts": [
  163. {
  164. "name": "${DATABASE_SERVICE_NAME}-data",
  165. "mountPath": "/var/lib/mysql/data"
  166. }
  167. ],
  168. "imagePullPolicy": "IfNotPresent"
  169. }
  170. ],
  171. "volumes": [
  172. {
  173. "name": "${DATABASE_SERVICE_NAME}-data",
  174. "emptyDir": {
  175. "medium": ""
  176. }
  177. }
  178. ]
  179. }
  180. }
  181. }
  182. }
  183. ],
  184. "parameters": [
  185. {
  186. "name": "MEMORY_LIMIT",
  187. "displayName": "Memory Limit",
  188. "description": "Maximum amount of memory the container can use.",
  189. "value": "512Mi",
  190. "required": true
  191. },
  192. {
  193. "name": "NAMESPACE",
  194. "displayName": "Namespace",
  195. "description": "The OpenShift Namespace where the ImageStream resides.",
  196. "value": "openshift"
  197. },
  198. {
  199. "name": "DATABASE_SERVICE_NAME",
  200. "displayName": "Database Service Name",
  201. "description": "The name of the OpenShift Service exposed for the database.",
  202. "value": "mariadb",
  203. "required": true
  204. },
  205. {
  206. "name": "MYSQL_USER",
  207. "displayName": "MariaDB Connection Username",
  208. "description": "Username for MariaDB user that will be used for accessing the database.",
  209. "generate": "expression",
  210. "from": "user[A-Z0-9]{3}",
  211. "required": true
  212. },
  213. {
  214. "name": "MYSQL_PASSWORD",
  215. "displayName": "MariaDB Connection Password",
  216. "description": "Password for the MariaDB connection user.",
  217. "generate": "expression",
  218. "from": "[a-zA-Z0-9]{16}",
  219. "required": true
  220. },
  221. {
  222. "name": "MYSQL_ROOT_PASSWORD",
  223. "displayName": "MariaDB root Password",
  224. "description": "Password for the MariaDB root user.",
  225. "generate": "expression",
  226. "from": "[a-zA-Z0-9]{16}",
  227. "required": true
  228. },
  229. {
  230. "name": "MYSQL_DATABASE",
  231. "displayName": "MariaDB Database Name",
  232. "description": "Name of the MariaDB database accessed.",
  233. "value": "sampledb",
  234. "required": true
  235. }
  236. ]
  237. }