MySQL
Helm chart for deploying mysql datastore
Install
Add the zop.dev chart repository, then install mysql into your cluster.
helm repo add zopdev https://helm.zop.dev
helm repo update
helm install my-mysql zopdev/mysql --version v0.0.18 The MySQL Helm chart provides an easy way to deploy and manage MySQL instances in your Kubernetes environment. This chart includes configurations for persistence, resource management, and scalability to suit various use cases.
Prerequisites
- Kubernetes 1.19+
- Helm 3+
Add Helm Repository
Before installing the MySQL chart, add the repository to your Helm installation and update the repository index:
helm repo add zopdev https://helm.zop.devhelm repo updateSee Helm Repository Documentation for more details.
Install Helm Chart
To install the MySQL Helm chart, run the following command:
helm install [RELEASE_NAME] zopdev/mysqlReplace [RELEASE_NAME] with your desired release name.
For example:
helm install my-mysql zopdev/mysqlYou can customize the installation by providing a custom values.yaml file or overriding values via the command line.
See Helm Install Documentation for further details.
Uninstall Helm Chart
To uninstall the MySQL Helm chart and remove all associated Kubernetes resources, run:
helm uninstall [RELEASE_NAME]For example:
helm uninstall my-mysqlSee Helm Uninstall Documentation for more information.
Configuration
The following table describes the configurable parameters of the MySQL Helm chart and their default values:
| Input | Type | Description | Default |
|---|---|---|---|
mysqlRootPassword | string | Root password for the MySQL instance. Leave unset for default random generation. | None |
updateStrategy.type | string | Update strategy for the deployment. Options: RollingUpdate or Recreate. | RollingUpdate |
diskSize | string | Size of the persistent volume claim (PVC) for storing MySQL data. | "10Gi" |
image | string | Docker image and tag for the MySQL container. | mysql:8.0 |
resources.requests.cpu | string | Minimum CPU resources required by the MySQL container. | "500m" |
resources.requests.memory | string | Minimum memory resources required by the MySQL container. | "256M" |
resources.limits.cpu | string | Maximum CPU resources the MySQL container can use. | "1500m" |
resources.limits.memory | string | Maximum memory resources the MySQL container can use. | "1Gi" |
customMyCnf | string | Custom MySQL configuration to be layered on top of the default config. Provided as a full INI file. | "" |
You can override these values in your values.yaml file or pass them as flags when installing the chart.
Example values.yaml File
diskSize: "10Gi"
# Resource configurationresources: requests: cpu: "500m" memory: "256M" limits: cpu: "1500m" memory: "1024M"
version: "8.0"
customMyCnf: ""To use this configuration, save it in a values.yaml file and pass it to the Helm install command:
helm install my-mysql zopdev/mysql -f values.yamlExample: Providing Custom MySQL Configuration
To override or add to the default MySQL configuration, provide your own my.cnf content using the customMyCnf value. This will be mounted as /etc/mysql/conf.d/custom.cnf in the container and layered on top of the default config.
Example values.yaml:
customMyCnf: | [mysqld] max_connections = 200 sql_mode = STRICT_ALL_TABLESThis allows you to specify any MySQL configuration options you need, without losing the chart’s defaults.
Features
- Persistence: The chart supports persistent volume claims to store MySQL data across pod restarts.
- Customizable Resources: Define resource requests and limits to optimize performance and manage costs.
- Scalable: Use the
updateStrategyconfiguration to handle updates with zero downtime. - Pre-configured Settings: Defaults are optimized for a variety of workloads.
Advanced Usage
Custom Secrets for Root Password
You can provide a pre-existing Kubernetes secret for the MySQL root password. To enable this, modify the values.yaml file with the secret name:
mysqlRootPassword: secretName: my-mysql-secretEnsure the secret is created before deploying the chart:
kubectl create secret generic my-mysql-secret --from-literal=mysql-root-password=my-secure-passwordPod Scheduling
nodeSelector, tolerations and affinity are passed straight through to the pod spec. All three are empty by default and render nothing, so leaving them unset changes nothing for an existing release.
Together they place the workload on a dedicated node pool — the nodeSelector picks the pool, the toleration gets past its taint:
nodeSelector: workload: stateful
tolerations: - key: workload operator: Equal value: stateful effect: NoScheduleaffinity takes a full Affinity object and is rendered verbatim.
Contributing
We welcome contributions to improve this Helm chart. Please refer to the CONTRIBUTING.md file for guidelines.
Code of Conduct
To ensure a respectful and collaborative community, please adhere to our Code of Conduct.
License
This project is licensed under the LICENSE. Please review it for terms of use.
Connection Config
- DB_DIALECT : Specifies the database dialect .In this context always set “mysql” .
- DB_USER: Username used to connect to mysql database.
- DB_PORT : The port number used to connect to the MySQL server.Defaults at 3306 .
- DB_NAME : The name of the specific database to connect to.
- DB_HOST : The hostname or service name of the MySQL server.
- DB_PASSWORD : The password for DB_USER stored securely by Kubernetes secrets.