You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 24 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. # ⚠️ Repo Archive Notice
  2. As of Nov 13, 2020, charts in this repo will no longer be updated.
  3. For more information, see the Helm Charts [Deprecation and Archive Notice](https://github.com/helm/charts#%EF%B8%8F-deprecation-and-archive-notice), and [Update](https://helm.sh/blog/charts-repo-deprecation/).
  4. # MySQL
  5. [MySQL](https://MySQL.org) is one of the most popular database servers in the world. Notable users include Wikipedia, Facebook and Google.
  6. ## DEPRECATION NOTICE
  7. This chart is deprecated and no longer supported.
  8. ## Introduction
  9. This chart bootstraps a single node MySQL deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
  10. ## Prerequisites
  11. - Kubernetes 1.10+ with Beta APIs enabled
  12. - PV provisioner support in the underlying infrastructure
  13. ## Installing the Chart
  14. To install the chart with the release name `my-release`:
  15. ```bash
  16. $ helm install --name my-release stable/mysql
  17. ```
  18. The command deploys MySQL on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.
  19. By default a random password will be generated for the root user. If you'd like to set your own password change the mysqlRootPassword
  20. in the values.yaml.
  21. You can retrieve your root password by running the following command. Make sure to replace [YOUR_RELEASE_NAME]:
  22. printf $(printf '\%o' `kubectl get secret [YOUR_RELEASE_NAME]-mysql -o jsonpath="{.data.mysql-root-password[*]}"`)
  23. > **Tip**: List all releases using `helm list`
  24. ## Uninstalling the Chart
  25. To uninstall/delete the `my-release` deployment:
  26. ```bash
  27. $ helm delete --purge my-release
  28. ```
  29. The command removes all the Kubernetes components associated with the chart and deletes the release completely.
  30. ## Configuration
  31. The following table lists the configurable parameters of the MySQL chart and their default values.
  32. | Parameter | Description | Default |
  33. | -------------------------------------------- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
  34. | `args` | Additional arguments to pass to the MySQL container. | `[]` |
  35. | `initContainer.resources` | initContainer resource requests/limits | Memory: `10Mi`, CPU: `10m` |
  36. | `image` | `mysql` image repository. | `mysql` |
  37. | `imageTag` | `mysql` image tag. | `5.7.30` |
  38. | `busybox.image` | `busybox` image repository. | `busybox` |
  39. | `busybox.tag` | `busybox` image tag. | `1.32` |
  40. | `testFramework.enabled` | `test-framework` switch. | `true` |
  41. | `testFramework.image` | `test-framework` image repository. | `bats/bats` |
  42. | `testFramework.tag` | `test-framework` image tag. | `1.2.1` |
  43. | `testFramework.imagePullPolicy` | `test-framework` image pull policy. | `IfNotPresent` |
  44. | `testFramework.securityContext` | `test-framework` securityContext | `{}` |
  45. | `imagePullPolicy` | Image pull policy | `IfNotPresent` |
  46. | `existingSecret` | Use Existing secret for Password details | `nil` |
  47. | `extraVolumes` | Additional volumes as a string to be passed to the `tpl` function | |
  48. | `extraVolumeMounts` | Additional volumeMounts as a string to be passed to the `tpl` function | |
  49. | `extraInitContainers` | Additional init containers as a string to be passed to the `tpl` function | |
  50. | `extraEnvVars` | Additional environment variables as a string to be passed to the `tpl` function | |
  51. | `mysqlRootPassword` | Password for the `root` user. Ignored if existing secret is provided | Random 10 characters |
  52. | `mysqlUser` | Username of new user to create. | `nil` |
  53. | `mysqlPassword` | Password for the new user. Ignored if existing secret is provided | Random 10 characters |
  54. | `mysqlDatabase` | Name for new database to create. | `nil` |
  55. | `livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | 30 |
  56. | `livenessProbe.periodSeconds` | How often to perform the probe | 10 |
  57. | `livenessProbe.timeoutSeconds` | When the probe times out | 5 |
  58. | `livenessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed. | 1 |
  59. | `livenessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 3 |
  60. | `readinessProbe.initialDelaySeconds` | Delay before readiness probe is initiated | 5 |
  61. | `readinessProbe.periodSeconds` | How often to perform the probe | 10 |
  62. | `readinessProbe.timeoutSeconds` | When the probe times out | 1 |
  63. | `readinessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed. | 1 |
  64. | `readinessProbe.failureThreshold` | Minimum consecutive failures for the probe to be considered failed after having succeeded. | 3 |
  65. | `schedulerName` | Name of the k8s scheduler (other than default) | `nil` |
  66. | `mysqlx.port.enabled` | Boolean to toggle a port for mysqlx `33060` protocol. | false |
  67. | `persistence.enabled` | Create a volume to store data | true |
  68. | `persistence.size` | Size of persistent volume claim | 8Gi RW |
  69. | `persistence.storageClass` | Type of persistent volume claim | nil |
  70. | `persistence.accessMode` | ReadWriteOnce or ReadOnly | ReadWriteOnce |
  71. | `persistence.existingClaim` | Name of existing persistent volume | `nil` |
  72. | `persistence.subPath` | Subdirectory of the volume to mount | `nil` |
  73. | `persistence.annotations` | Persistent Volume annotations | {} |
  74. | `nodeSelector` | Node labels for pod assignment | {} |
  75. | `affinity` | Affinity rules for pod assignment | {} |
  76. | `tolerations` | Pod taint tolerations for deployment | {} |
  77. | `metrics.enabled` | Start a side-car prometheus exporter | `false` |
  78. | `metrics.image` | Exporter image | `prom/mysqld-exporter` |
  79. | `metrics.imageTag` | Exporter image | `v0.10.0` |
  80. | `metrics.imagePullPolicy` | Exporter image pull policy | `IfNotPresent` |
  81. | `metrics.resources` | Exporter resource requests/limit | `nil` |
  82. | `metrics.livenessProbe.initialDelaySeconds` | Delay before metrics liveness probe is initiated | 15 |
  83. | `metrics.livenessProbe.timeoutSeconds` | When the probe times out | 5 |
  84. | `metrics.readinessProbe.initialDelaySeconds` | Delay before metrics readiness probe is initiated | 5 |
  85. | `metrics.readinessProbe.timeoutSeconds` | When the probe times out | 1 |
  86. | `metrics.flags` | Additional flags for the mysql exporter to use | `[]` |
  87. | `metrics.serviceMonitor.enabled` | Set this to `true` to create ServiceMonitor for Prometheus operator | `false` |
  88. | `metrics.serviceMonitor.additionalLabels` | Additional labels that can be used so ServiceMonitor will be discovered by Prometheus | `{}` |
  89. | `resources` | CPU/Memory resource requests/limits | Memory: `256Mi`, CPU: `100m` |
  90. | `configurationFiles` | List of mysql configuration files | `nil` |
  91. | `configurationFilesPath` | Path of mysql configuration files | `/etc/mysql/conf.d/` |
  92. | `securityContext.enabled` | Enable security context (mysql pod) | `false` |
  93. | `securityContext.fsGroup` | Group ID for the container (mysql pod) | 999 |
  94. | `securityContext.runAsUser` | User ID for the container (mysql pod) | 999 |
  95. | `service.annotations` | Kubernetes annotations for mysql | {} |
  96. | `service.type` | Kubernetes service type | ClusterIP |
  97. | `service.loadBalancerIP` | LoadBalancer service IP | `""` |
  98. | `serviceAccount.create` | Specifies whether a ServiceAccount should be created | `false` |
  99. | `serviceAccount.name` | The name of the ServiceAccount to create | Generated using the mysql.fullname template |
  100. | `ssl.enabled` | Setup and use SSL for MySQL connections | `false` |
  101. | `ssl.secret` | Name of the secret containing the SSL certificates | mysql-ssl-certs |
  102. | `ssl.certificates[0].name` | Name of the secret containing the SSL certificates | `nil` |
  103. | `ssl.certificates[0].ca` | CA certificate | `nil` |
  104. | `ssl.certificates[0].cert` | Server certificate (public key) | `nil` |
  105. | `ssl.certificates[0].key` | Server key (private key) | `nil` |
  106. | `imagePullSecrets` | Name of Secret resource containing private registry credentials | `nil` |
  107. | `initializationFiles` | List of SQL files which are run after the container started | `nil` |
  108. | `timezone` | Container and mysqld timezone (TZ env) | `nil` (UTC depending on image) |
  109. | `podAnnotations` | Map of annotations to add to the pods | `{}` |
  110. | `podLabels` | Map of labels to add to the pods | `{}` |
  111. | `priorityClassName` | Set pod priorityClassName | `{}` |
  112. | `deploymentAnnotations` | Map of annotations for deployment | `{}` |
  113. | `strategy` | Update strategy policy | `{type: "Recreate"}` |
  114. Some of the parameters above map to the env variables defined in the [MySQL DockerHub image](https://hub.docker.com/_/mysql/).
  115. Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
  116. ```bash
  117. $ helm install --name my-release \
  118. --set mysqlRootPassword=secretpassword,mysqlUser=my-user,mysqlPassword=my-password,mysqlDatabase=my-database \
  119. stable/mysql
  120. ```
  121. The above command sets the MySQL `root` account password to `secretpassword`. Additionally it creates a standard database user named `my-user`, with the password `my-password`, who has access to a database named `my-database`.
  122. Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,
  123. ```bash
  124. $ helm install --name my-release -f values.yaml stable/mysql
  125. ```
  126. > **Tip**: You can use the default [values.yaml](values.yaml)
  127. ## Persistence
  128. The [MySQL](https://hub.docker.com/_/mysql/) image stores the MySQL data and configurations at the `/var/lib/mysql` path of the container.
  129. By default a PersistentVolumeClaim is created and mounted into that directory. In order to disable this functionality
  130. you can change the values.yaml to disable persistence and use an emptyDir instead.
  131. > *"An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever."*
  132. **Notice**: You may need to increase the value of `livenessProbe.initialDelaySeconds` when enabling persistence by using PersistentVolumeClaim from PersistentVolume with varying properties. Since its IO performance has impact on the database initialization performance. The default limit for database initialization is `60` seconds (`livenessProbe.initialDelaySeconds` + `livenessProbe.periodSeconds` * `livenessProbe.failureThreshold`). Once such initialization process takes more time than this limit, kubelet will restart the database container, which will interrupt database initialization then causing persisent data in an unusable state.
  133. ## Custom MySQL configuration files
  134. The [MySQL](https://hub.docker.com/_/mysql/) image accepts custom configuration files at the path `/etc/mysql/conf.d`. If you want to use a customized MySQL configuration, you can create your alternative configuration files by passing the file contents on the `configurationFiles` attribute. Note that according to the MySQL documentation only files ending with `.cnf` are loaded.
  135. ```yaml
  136. configurationFiles:
  137. mysql.cnf: |-
  138. [mysqld]
  139. skip-host-cache
  140. skip-name-resolve
  141. sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
  142. mysql_custom.cnf: |-
  143. [mysqld]
  144. ```
  145. ## MySQL initialization files
  146. The [MySQL](https://hub.docker.com/_/mysql/) image accepts *.sh, *.sql and *.sql.gz files at the path `/docker-entrypoint-initdb.d`.
  147. These files are being run exactly once for container initialization and ignored on following container restarts.
  148. If you want to use initialization scripts, you can create initialization files by passing the file contents on the `initializationFiles` attribute.
  149. ```yaml
  150. initializationFiles:
  151. first-db.sql: |-
  152. CREATE DATABASE IF NOT EXISTS first DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
  153. second-db.sql: |-
  154. CREATE DATABASE IF NOT EXISTS second DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
  155. ```
  156. ## SSL
  157. This chart supports configuring MySQL to use [encrypted connections](https://dev.mysql.com/doc/refman/5.7/en/encrypted-connections.html) with TLS/SSL certificates provided by the user. This is accomplished by storing the required Certificate Authority file, the server public key certificate, and the server private key as a Kubernetes secret. The SSL options for this chart support the following use cases:
  158. * Manage certificate secrets with helm
  159. * Manage certificate secrets outside of helm
  160. ## Manage certificate secrets with helm
  161. Include your certificate data in the `ssl.certificates` section. For example:
  162. ```
  163. ssl:
  164. enabled: false
  165. secret: mysql-ssl-certs
  166. certificates:
  167. - name: mysql-ssl-certs
  168. ca: |-
  169. -----BEGIN CERTIFICATE-----
  170. ...
  171. -----END CERTIFICATE-----
  172. cert: |-
  173. -----BEGIN CERTIFICATE-----
  174. ...
  175. -----END CERTIFICATE-----
  176. key: |-
  177. -----BEGIN RSA PRIVATE KEY-----
  178. ...
  179. -----END RSA PRIVATE KEY-----
  180. ```
  181. > **Note**: Make sure your certificate data has the correct formatting in the values file.
  182. ## Manage certificate secrets outside of helm
  183. 1. Ensure the certificate secret exist before installation of this chart.
  184. 2. Set the name of the certificate secret in `ssl.secret`.
  185. 3. Make sure there are no entries underneath `ssl.certificates`.
  186. To manually create the certificate secret from local files you can execute:
  187. ```
  188. kubectl create secret generic mysql-ssl-certs \
  189. --from-file=ca.pem=./ssl/certificate-authority.pem \
  190. --from-file=server-cert.pem=./ssl/server-public-key.pem \
  191. --from-file=server-key.pem=./ssl/server-private-key.pem
  192. ```
  193. > **Note**: `ca.pem`, `server-cert.pem`, and `server-key.pem` **must** be used as the key names in this generic secret.
  194. If you are using a certificate your configurationFiles must include the three ssl lines under [mysqld]
  195. ```
  196. [mysqld]
  197. ssl-ca=/ssl/ca.pem
  198. ssl-cert=/ssl/server-cert.pem
  199. ssl-key=/ssl/server-key.pem
  200. ```