mariadb-persistent-template.json 12 KB

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