mariadb-ephemeral-template.json 11 KB

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