mariadb-persistent-template.json 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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. "template.openshift.io/long-description": "This template provides a standalone MariaDB server with a database created. The database is stored on persistent storage. 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": "PersistentVolumeClaim",
  62. "apiVersion": "v1",
  63. "metadata": {
  64. "name": "${DATABASE_SERVICE_NAME}"
  65. },
  66. "spec": {
  67. "accessModes": [
  68. "ReadWriteOnce"
  69. ],
  70. "resources": {
  71. "requests": {
  72. "storage": "${VOLUME_CAPACITY}"
  73. }
  74. }
  75. }
  76. },
  77. {
  78. "kind": "DeploymentConfig",
  79. "apiVersion": "v1",
  80. "metadata": {
  81. "name": "${DATABASE_SERVICE_NAME}"
  82. },
  83. "spec": {
  84. "strategy": {
  85. "type": "Recreate"
  86. },
  87. "triggers": [
  88. {
  89. "type": "ImageChange",
  90. "imageChangeParams": {
  91. "automatic": true,
  92. "containerNames": [
  93. "mariadb"
  94. ],
  95. "from": {
  96. "kind": "ImageStreamTag",
  97. "name": "mariadb:10.1",
  98. "namespace": "${NAMESPACE}"
  99. }
  100. }
  101. },
  102. {
  103. "type": "ConfigChange"
  104. }
  105. ],
  106. "replicas": 1,
  107. "selector": {
  108. "name": "${DATABASE_SERVICE_NAME}"
  109. },
  110. "template": {
  111. "metadata": {
  112. "labels": {
  113. "name": "${DATABASE_SERVICE_NAME}"
  114. }
  115. },
  116. "spec": {
  117. "containers": [
  118. {
  119. "name": "mariadb",
  120. "image": " ",
  121. "ports": [
  122. {
  123. "containerPort": 3306
  124. }
  125. ],
  126. "readinessProbe": {
  127. "timeoutSeconds": 1,
  128. "initialDelaySeconds": 5,
  129. "exec": {
  130. "command": [ "/bin/sh", "-i", "-c",
  131. "MYSQL_PWD=\"$MYSQL_PASSWORD\" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'"]
  132. }
  133. },
  134. "livenessProbe": {
  135. "timeoutSeconds": 1,
  136. "initialDelaySeconds": 30,
  137. "tcpSocket": {
  138. "port": 3306
  139. }
  140. },
  141. "env": [
  142. {
  143. "name": "MYSQL_USER",
  144. "valueFrom": {
  145. "secretKeyRef" : {
  146. "name" : "${DATABASE_SERVICE_NAME}",
  147. "key" : "database-user"
  148. }
  149. }
  150. },
  151. {
  152. "name": "MYSQL_PASSWORD",
  153. "valueFrom": {
  154. "secretKeyRef" : {
  155. "name" : "${DATABASE_SERVICE_NAME}",
  156. "key" : "database-password"
  157. }
  158. }
  159. },
  160. {
  161. "name": "MYSQL_ROOT_PASSWORD",
  162. "valueFrom": {
  163. "secretKeyRef" : {
  164. "name" : "${DATABASE_SERVICE_NAME}",
  165. "key" : "database-root-password"
  166. }
  167. }
  168. },
  169. {
  170. "name": "MYSQL_DATABASE",
  171. "value": "${MYSQL_DATABASE}"
  172. }
  173. ],
  174. "resources": {
  175. "limits": {
  176. "memory": "${MEMORY_LIMIT}"
  177. }
  178. },
  179. "volumeMounts": [
  180. {
  181. "name": "${DATABASE_SERVICE_NAME}-data",
  182. "mountPath": "/var/lib/mysql/data"
  183. }
  184. ],
  185. "imagePullPolicy": "IfNotPresent"
  186. }
  187. ],
  188. "volumes": [
  189. {
  190. "name": "${DATABASE_SERVICE_NAME}-data",
  191. "persistentVolumeClaim": {
  192. "claimName": "${DATABASE_SERVICE_NAME}"
  193. }
  194. }
  195. ]
  196. }
  197. }
  198. }
  199. }
  200. ],
  201. "parameters": [
  202. {
  203. "name": "MEMORY_LIMIT",
  204. "displayName": "Memory Limit",
  205. "description": "Maximum amount of memory the container can use.",
  206. "value": "512Mi",
  207. "required": true
  208. },
  209. {
  210. "name": "NAMESPACE",
  211. "displayName": "Namespace",
  212. "description": "The OpenShift Namespace where the ImageStream resides.",
  213. "value": "openshift"
  214. },
  215. {
  216. "name": "DATABASE_SERVICE_NAME",
  217. "displayName": "Database Service Name",
  218. "description": "The name of the OpenShift Service exposed for the database.",
  219. "value": "mariadb",
  220. "required": true
  221. },
  222. {
  223. "name": "MYSQL_USER",
  224. "displayName": "MariaDB Connection Username",
  225. "description": "Username for MariaDB user that will be used for accessing the database.",
  226. "generate": "expression",
  227. "from": "user[A-Z0-9]{3}",
  228. "required": true
  229. },
  230. {
  231. "name": "MYSQL_PASSWORD",
  232. "displayName": "MariaDB Connection Password",
  233. "description": "Password for the MariaDB connection user.",
  234. "generate": "expression",
  235. "from": "[a-zA-Z0-9]{16}",
  236. "required": true
  237. },
  238. {
  239. "name": "MYSQL_ROOT_PASSWORD",
  240. "displayName": "MariaDB root Password",
  241. "description": "Password for the MariaDB root user.",
  242. "generate": "expression",
  243. "from": "[a-zA-Z0-9]{16}",
  244. "required": true
  245. },
  246. {
  247. "name": "MYSQL_DATABASE",
  248. "displayName": "MariaDB Database Name",
  249. "description": "Name of the MariaDB database accessed.",
  250. "value": "sampledb",
  251. "required": true
  252. },
  253. {
  254. "name": "VOLUME_CAPACITY",
  255. "displayName": "Volume Capacity",
  256. "description": "Volume space available for data, e.g. 512Mi, 2Gi.",
  257. "value": "1Gi",
  258. "required": true
  259. }
  260. ]
  261. }