mariadb-persistent-template.json 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. {
  2. "kind": "Template",
  3. "apiVersion": "v1",
  4. "metadata": {
  5. "name": "mariadb-persistent",
  6. "annotations": {
  7. "openshift.io/display-name": "MariaDB (Persistent)",
  8. "description": "MariaDB database service, with 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\nNOTE: Scaling to more than one replica is not supported. You must have persistent volumes available in your cluster to use this template.",
  9. "iconClass": "icon-mariadb",
  10. "tags": "database,mariadb"
  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/mariadb-container/blob/master/10.1/README.md.",
  14. "labels": {
  15. "template": "mariadb-persistent-template"
  16. },
  17. "objects": [
  18. {
  19. "kind": "Service",
  20. "apiVersion": "v1",
  21. "metadata": {
  22. "name": "${DATABASE_SERVICE_NAME}"
  23. },
  24. "spec": {
  25. "ports": [
  26. {
  27. "name": "mariadb",
  28. "port": 3306
  29. }
  30. ],
  31. "selector": {
  32. "name": "${DATABASE_SERVICE_NAME}"
  33. }
  34. }
  35. },
  36. {
  37. "kind": "PersistentVolumeClaim",
  38. "apiVersion": "v1",
  39. "metadata": {
  40. "name": "${DATABASE_SERVICE_NAME}"
  41. },
  42. "spec": {
  43. "accessModes": [
  44. "ReadWriteOnce"
  45. ],
  46. "resources": {
  47. "requests": {
  48. "storage": "${VOLUME_CAPACITY}"
  49. }
  50. }
  51. }
  52. },
  53. {
  54. "kind": "DeploymentConfig",
  55. "apiVersion": "v1",
  56. "metadata": {
  57. "name": "${DATABASE_SERVICE_NAME}"
  58. },
  59. "spec": {
  60. "strategy": {
  61. "type": "Recreate"
  62. },
  63. "triggers": [
  64. {
  65. "type": "ImageChange",
  66. "imageChangeParams": {
  67. "automatic": true,
  68. "containerNames": [
  69. "mariadb"
  70. ],
  71. "from": {
  72. "kind": "ImageStreamTag",
  73. "name": "mariadb:10.1",
  74. "namespace": "${NAMESPACE}"
  75. }
  76. }
  77. },
  78. {
  79. "type": "ConfigChange"
  80. }
  81. ],
  82. "replicas": 1,
  83. "selector": {
  84. "name": "${DATABASE_SERVICE_NAME}"
  85. },
  86. "template": {
  87. "metadata": {
  88. "labels": {
  89. "name": "${DATABASE_SERVICE_NAME}"
  90. }
  91. },
  92. "spec": {
  93. "containers": [
  94. {
  95. "name": "mariadb",
  96. "image": " ",
  97. "ports": [
  98. {
  99. "containerPort": 3306
  100. }
  101. ],
  102. "readinessProbe": {
  103. "timeoutSeconds": 1,
  104. "initialDelaySeconds": 5,
  105. "exec": {
  106. "command": [ "/bin/sh", "-i", "-c",
  107. "MYSQL_PWD=\"$MYSQL_PASSWORD\" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'"]
  108. }
  109. },
  110. "livenessProbe": {
  111. "timeoutSeconds": 1,
  112. "initialDelaySeconds": 30,
  113. "tcpSocket": {
  114. "port": 3306
  115. }
  116. },
  117. "env": [
  118. {
  119. "name": "MYSQL_USER",
  120. "value": "${MYSQL_USER}"
  121. },
  122. {
  123. "name": "MYSQL_PASSWORD",
  124. "value": "${MYSQL_PASSWORD}"
  125. },
  126. {
  127. "name": "MYSQL_DATABASE",
  128. "value": "${MYSQL_DATABASE}"
  129. }
  130. ],
  131. "resources": {
  132. "limits": {
  133. "memory": "${MEMORY_LIMIT}"
  134. }
  135. },
  136. "volumeMounts": [
  137. {
  138. "name": "${DATABASE_SERVICE_NAME}-data",
  139. "mountPath": "/var/lib/mysql/data"
  140. }
  141. ],
  142. "imagePullPolicy": "IfNotPresent"
  143. }
  144. ],
  145. "volumes": [
  146. {
  147. "name": "${DATABASE_SERVICE_NAME}-data",
  148. "persistentVolumeClaim": {
  149. "claimName": "${DATABASE_SERVICE_NAME}"
  150. }
  151. }
  152. ]
  153. }
  154. }
  155. }
  156. }
  157. ],
  158. "parameters": [
  159. {
  160. "name": "MEMORY_LIMIT",
  161. "displayName": "Memory Limit",
  162. "description": "Maximum amount of memory the container can use.",
  163. "value": "512Mi",
  164. "required": true
  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": "mariadb",
  177. "required": true
  178. },
  179. {
  180. "name": "MYSQL_USER",
  181. "displayName": "MariaDB Connection Username",
  182. "description": "Username for MariaDB 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": "MariaDB Connection Password",
  190. "description": "Password for the MariaDB connection user.",
  191. "generate": "expression",
  192. "from": "[a-zA-Z0-9]{16}",
  193. "required": true
  194. },
  195. {
  196. "name": "MYSQL_DATABASE",
  197. "displayName": "MariaDB Database Name",
  198. "description": "Name of the MariaDB database accessed.",
  199. "value": "sampledb",
  200. "required": true
  201. },
  202. {
  203. "name": "VOLUME_CAPACITY",
  204. "displayName": "Volume Capacity",
  205. "description": "Volume space available for data, e.g. 512Mi, 2Gi.",
  206. "value": "1Gi",
  207. "required": true
  208. }
  209. ]
  210. }