Back to Charts

MariaDB

stable/mariadb/README.md

latest34.5 KB
Original Source

MariaDB

MariaDB is one of the most popular database servers in the world. It’s made by the original developers of MySQL and guaranteed to stay open source. Notable users include Wikipedia, Facebook and Google.

MariaDB is developed as open source software and as a relational database it provides an SQL interface for accessing data. The latest versions of MariaDB also include GIS and JSON features.

This Helm chart is deprecated

Given the stable deprecation timeline, the Bitnami maintained MariaDB Helm chart is now located at bitnami/charts.

The Bitnami repository is already included in the Hubs and we will continue providing the same cadence of updates, support, etc that we've been keeping here these years. Installation instructions are very similar, just adding the bitnami repo and using it during the installation (bitnami/<chart> instead of stable/<chart>)

bash
$ helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm install my-release bitnami/<chart>           # Helm 3
$ helm install --name my-release bitnami/<chart>    # Helm 2

To update an exisiting stable deployment with a chart hosted in the bitnami repository you can execute

bash
$ helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm upgrade my-release bitnami/<chart>

Issues and PRs related to the chart itself will be redirected to bitnami/charts GitHub repository. In the same way, we'll be happy to answer questions related to this migration process in this issue created as a common place for discussion.

TL;DR;

bash
$ helm install my-release stable/mariadb

Introduction

This chart bootstraps a MariaDB replication cluster deployment on a Kubernetes cluster using the Helm package manager.

Bitnami charts can be used with Kubeapps for deployment and management of Helm Charts in clusters. This chart has been tested to work with NGINX Ingress, cert-manager, fluentd and Prometheus on top of the BKPR.

Prerequisites

  • Kubernetes 1.12+
  • Helm 2.11+ or Helm 3.0-beta3+
  • PV provisioner support in the underlying infrastructure

Installing the Chart

To install the chart with the release name my-release:

bash
$ helm install my-release stable/mariadb

The command deploys MariaDB on the Kubernetes cluster in the default configuration. The Parameters section lists the parameters that can be configured during installation.

Tip: List all releases using helm list

Uninstalling the Chart

To uninstall/delete the my-release deployment:

bash
$ helm delete my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Parameters

The following table lists the configurable parameters of the MariaDB chart and their default values.

ParameterDescriptionDefault
global.imageRegistryGlobal Docker image registrynil
global.imagePullSecretsGlobal Docker registry secret names as an array[] (does not add image pull secrets to deployed pods)
global.storageClassGlobal storage class for dynamic provisioningnil
image.registryMariaDB image registrydocker.io
image.repositoryMariaDB Image namebitnami/mariadb
image.tagMariaDB Image tag{TAG_NAME}
image.pullPolicyMariaDB image pull policyIfNotPresent
image.pullSecretsSpecify docker-registry secret names as an array[] (does not add image pull secrets to deployed pods)
image.debugSpecify if debug logs should be enabledfalse
nameOverrideString to partially override mariadb.fullname template with a string (will prepend the release name)nil
fullnameOverrideString to fully override mariadb.fullname template with a stringnil
volumePermissions.enabledEnable init container that changes volume permissions in the data directory (for cases where the default k8s runAsUser and fsUser values do not work)false
volumePermissions.image.registryInit container volume-permissions image registrydocker.io
volumePermissions.image.repositoryInit container volume-permissions image namebitnami/minideb
volumePermissions.image.tagInit container volume-permissions image tagbuster
volumePermissions.image.pullPolicyInit container volume-permissions image pull policyAlways
volumePermissions.resourcesInit container resource requests/limitnil
service.typeKubernetes service typeClusterIP
service.clusterIp.masterSpecific cluster IP for master when service type is cluster IP. Use None for headless servicenil
service.clusterIp.slaveSpecific cluster IP for slave when service type is cluster IP. Use None for headless servicenil
service.portMySQL service port3306
serviceAccount.createSpecifies whether a ServiceAccount should be createdfalse
serviceAccount.nameThe name of the ServiceAccount to createGenerated using the mariadb.fullname template
schedulerNameName of the k8s scheduler (other than default)nil
rbac.createCreate and use RBAC resourcesfalse
securityContext.enabledEnable security contexttrue
securityContext.fsGroupGroup ID for the container1001
securityContext.runAsUserUser ID for the container1001
existingSecretUse existing secret for password details (rootUser.password, db.password, replication.password will be ignored and picked up from this secret). The secret has to contain the keys mariadb-root-password, mariadb-replication-password and mariadb-password.nil
rootUser.passwordPassword for the root user. Ignored if existing secret is provided.random 10 character alphanumeric string
rootUser.forcePasswordForce users to specify a passwordfalse
rootUser.injectSecretsAsVolumeMount admin user password as a file instead of using an environment variablefalse
db.nameName for new database to createmy_database
db.userUsername of new user to create""
db.passwordPassword for the new user. Ignored if existing secret is provided.random 10 character alphanumeric string if db.user is defined
db.forcePasswordForce users to specify a passwordfalse
db.injectSecretsAsVolumeMount user password as a file instead of using an environment variablefalse
replication.enabledMariaDB replication enabledtrue
replication.userMariaDB replication userreplicator
replication.passwordMariaDB replication user password. Ignored if existing secret is provided.random 10 character alphanumeric string
replication.forcePasswordForce users to specify a passwordfalse
replication.injectSecretsAsVolumeMount replication user password as a file instead of using an environment variablefalse
initdbScriptsDictionary of initdb scriptsnil
initdbScriptsConfigMapConfigMap with the initdb scripts (Note: Overrides initdbScripts)nil
master.annotations[].keykey for the the annotation list itemnil
master.annotations[].valuevalue for the the annotation list itemnil
master.extraFlagsMariaDB master additional command line flagsnil
master.affinityMaster affinity (in addition to master.antiAffinity when set){}
master.antiAffinityMaster pod anti-affinity policysoft
master.nodeSelectorMaster node labels for pod assignment{}
master.tolerationsList of node taints to tolerate (master)[]
master.updateStrategyMaster statefulset update strategy policyRollingUpdate
master.persistence.enabledEnable persistence using PVCtrue
master.persistence.existingClaimProvide an existing PersistentVolumeClaimnil
master.persistence.subPathSubdirectory of the volume to mountnil
master.persistence.mountPathPath to mount the volume at/bitnami/mariadb
master.persistence.annotationsPersistent Volume Claim annotations{}
master.persistence.storageClassPersistent Volume Storage Class``
master.persistence.accessModesPersistent Volume Access Modes[ReadWriteOnce]
master.persistence.sizePersistent Volume Size8Gi
master.extraInitContainersAdditional init containers as a string to be passed to the tpl function (master)
master.extraEnvVarsArray containing extra env vars to configure MariaDB master replicasnil
master.configConfig file for the MariaDB Master server_default values in the values.yaml file_
master.resourcesCPU/Memory resource requests/limits for master node{}
master.livenessProbe.enabledTurn on and off liveness probe (master)true
master.livenessProbe.initialDelaySecondsDelay before liveness probe is initiated (master)120
master.livenessProbe.periodSecondsHow often to perform the probe (master)10
master.livenessProbe.timeoutSecondsWhen the probe times out (master)1
master.livenessProbe.successThresholdMinimum consecutive successes for the probe (master)1
master.livenessProbe.failureThresholdMinimum consecutive failures for the probe (master)3
master.readinessProbe.enabledTurn on and off readiness probe (master)true
master.readinessProbe.initialDelaySecondsDelay before readiness probe is initiated (master)30
master.readinessProbe.periodSecondsHow often to perform the probe (master)10
master.readinessProbe.timeoutSecondsWhen the probe times out (master)1
master.readinessProbe.successThresholdMinimum consecutive successes for the probe (master)1
master.readinessProbe.failureThresholdMinimum consecutive failures for the probe (master)3
master.podDisruptionBudget.enabledIf true, create a pod disruption budget for master pods.false
master.podDisruptionBudget.minAvailableMinimum number / percentage of pods that should remain scheduled1
master.podDisruptionBudget.maxUnavailableMaximum number / percentage of pods that may be made unavailablenil
master.service.annotationsMaster service annotations{}
slave.replicasDesired number of slave replicas1
slave.annotations[].keykey for the the annotation list itemnil
slave.annotations[].valuevalue for the the annotation list itemnil
slave.extraFlagsMariaDB slave additional command line flagsnil
slave.affinitySlave affinity (in addition to slave.antiAffinity when set){}
slave.antiAffinitySlave pod anti-affinity policysoft
slave.nodeSelectorSlave node labels for pod assignment{}
slave.tolerationsList of node taints to tolerate for (slave)[]
slave.updateStrategySlave statefulset update strategy policyRollingUpdate
slave.persistence.enabledEnable persistence using a PersistentVolumeClaimtrue
slave.persistence.annotationsPersistent Volume Claim annotations{}
slave.persistence.storageClassPersistent Volume Storage Class``
slave.persistence.accessModesPersistent Volume Access Modes[ReadWriteOnce]
slave.persistence.sizePersistent Volume Size8Gi
slave.extraInitContainersAdditional init containers as a string to be passed to the tpl function (slave)nil
slave.extraEnvVarsArray containing extra env vars to configure MariaDB slave replicasnil
slave.configConfig file for the MariaDB Slave replicas_default values in the values.yaml file_
slave.resourcesCPU/Memory resource requests/limits for slave node{}
slave.livenessProbe.enabledTurn on and off liveness probe (slave)true
slave.livenessProbe.initialDelaySecondsDelay before liveness probe is initiated (slave)120
slave.livenessProbe.periodSecondsHow often to perform the probe (slave)10
slave.livenessProbe.timeoutSecondsWhen the probe times out (slave)1
slave.livenessProbe.successThresholdMinimum consecutive successes for the probe (slave)1
slave.livenessProbe.failureThresholdMinimum consecutive failures for the probe (slave)3
slave.readinessProbe.enabledTurn on and off readiness probe (slave)true
slave.readinessProbe.initialDelaySecondsDelay before readiness probe is initiated (slave)45
slave.readinessProbe.periodSecondsHow often to perform the probe (slave)10
slave.readinessProbe.timeoutSecondsWhen the probe times out (slave)1
slave.readinessProbe.successThresholdMinimum consecutive successes for the probe (slave)1
slave.readinessProbe.failureThresholdMinimum consecutive failures for the probe (slave)3
slave.podDisruptionBudget.enabledIf true, create a pod disruption budget for slave pods.false
slave.podDisruptionBudget.minAvailableMinimum number / percentage of pods that should remain scheduled1
slave.podDisruptionBudget.maxUnavailableMaximum number / percentage of pods that may be made unavailablenil
slave.service.annotationsSlave service annotations{}
metrics.enabledStart a side-car prometheus exporterfalse
metrics.image.registryExporter image registrydocker.io
metrics.image.repositoryExporter image namebitnami/mysqld-exporter
metrics.image.tagExporter image tag{TAG_NAME}
metrics.image.pullPolicyExporter image pull policyIfNotPresent
metrics.resourcesExporter resource requests/limitnil
metrics.extraArgs.masterExtra args to be passed to mysqld_exporter[]
metrics.extraArgs.slaveExtra args to be passed to mysqld_exporter[]
metrics.livenessProbe.enabledTurn on and off liveness probe (metrics)true
metrics.livenessProbe.initialDelaySecondsDelay before liveness probe is initiated (metrics)120
metrics.livenessProbe.periodSecondsHow often to perform the probe (metrics)10
metrics.livenessProbe.timeoutSecondsWhen the probe times out (metrics)1
metrics.livenessProbe.successThresholdMinimum consecutive successes for the probe (metrics)1
metrics.livenessProbe.failureThresholdMinimum consecutive failures for the probe (metrics)3
metrics.readinessProbe.enabledTurn on and off readiness probe (metrics)true
metrics.readinessProbe.initialDelaySecondsDelay before readiness probe is initiated (metrics)30
metrics.readinessProbe.periodSecondsHow often to perform the probe (metrics)10
metrics.readinessProbe.timeoutSecondsWhen the probe times out (metrics)1
metrics.readinessProbe.successThresholdMinimum consecutive successes for the probe (metrics)1
metrics.readinessProbe.failureThresholdMinimum consecutive failures for the probe (metrics)3
metrics.serviceMonitor.enabledif true, creates a Prometheus Operator ServiceMonitor (also requires metrics.enabled to be true)false
metrics.serviceMonitor.namespaceOptional namespace which Prometheus is running innil
metrics.serviceMonitor.intervalHow frequently to scrape metrics (use by default, falling back to Prometheus' default)nil
metrics.serviceMonitor.selectorDefault to kube-prometheus install (CoreOS recommended), but should be set according to Prometheus install{ prometheus: kube-prometheus }
tests.enabledProvide tests to check if connect and authentication is possibletrue
tests.resourcesResource definition for the test-runner podnil
tests.testFramework.image.registryTest framework image registry (init container)docker.io
tests.testFramework.image.repositoryTest framework image namedduportal/bats
tests.testFramework.image.tagTest framework image tag0.4.0
tests.testFramework.resourcesResource definition for the test frameworknil

The above parameters map to the env variables defined in bitnami/mariadb. For more information please refer to the bitnami/mariadb image documentation.

Specify each parameter using the --set key=value[,key=value] argument to helm install. For example,

bash
$ helm install my-release \
  --set rootUser.password=secretpassword,db.user=app_database \
    stable/mariadb

The above command sets the MariaDB root account password to secretpassword. Additionally it creates a database named my_database.

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

bash
$ helm install my-release -f values.yaml stable/mariadb

Tip: You can use the default values.yaml

Configuration and installation details

Rolling VS Immutable tags

It is strongly recommended to use immutable tags in a production environment. This ensures your deployment does not change automatically if the same tag is updated with a different image.

Bitnami will release a new chart updating its containers if a new version of the main container, significant changes, or critical vulnerabilities exist.

Production configuration

This chart includes a values-production.yaml file where you can find some parameters oriented to production configuration in comparison to the regular values.yaml. You can use this file instead of the default one.

  • Force users to specify a password and mount secrets as volumes instead of using environment variables:
diff
- rootUser.forcePassword: false
- rootUser.injectSecretsAsVolume: false
+ rootUser.forcePassword: true
+ rootUser.injectSecretsAsVolume: true
- db.forcePassword: false
- db.injectSecretsAsVolume: false
+ db.forcePassword: true
+ db.injectSecretsAsVolume: true
- replication.forcePassword: false
- replication.injectSecretsAsVolume: false
+ replication.forcePassword: true
+ replication.injectSecretsAsVolume: true
  • Desired number of slave replicas:
diff
- slave.replicas: 1
+ slave.replicas: 2
  • Start a side-car prometheus exporter:
diff
- metrics.enabled: false
+ metrics.enabled: true

Initialize a fresh instance

The Bitnami MariaDB image allows you to use your custom scripts to initialize a fresh instance. In order to execute the scripts, they must be located inside the chart folder files/docker-entrypoint-initdb.d so they can be consumed as a ConfigMap.

Alternatively, you can specify custom scripts using the initdbScripts parameter as dict.

In addition to these options, you can also set an external ConfigMap with all the initialization scripts. This is done by setting the initdbScriptsConfigMap parameter. Note that this will override the two previous options.

The allowed extensions are .sh, .sql and .sql.gz.

Extra Init Containers

The feature allows for specifying a template string for a initContainer in the master/slave pod. Usecases include situations when you need some pre-run setup. For example, in IKS (IBM Cloud Kubernetes Service), non-root users do not have write permission on the volume mount path for NFS-powered file storage. So, you could use a initcontainer to chown the mount. See a example below, where we add an initContainer on the master pod that reports to an external resource that the db is going to starting. values.yaml

yaml
master:
  extraInitContainers: |
    - name: initcontainer
      image: bitnami/minideb:buster
      command: ["/bin/sh", "-c"]
      args:
        - install_packages curl && curl http://api-service.local/db/starting;

Persistence

The Bitnami MariaDB image stores the MariaDB data and configurations at the /bitnami/mariadb path of the container.

The chart mounts a Persistent Volume volume at this location. The volume is created using dynamic volume provisioning, by default. An existing PersistentVolumeClaim can be defined.

Adjust permissions of persistent volume mountpoint

As the image run as non-root by default, it is necessary to adjust the ownership of the persistent volume so that the container can write data into it.

By default, the chart is configured to use Kubernetes Security Context to automatically change the ownership of the volume. However, this feature does not work in all Kubernetes distributions. As an alternative, this chart supports using an initContainer to change the ownership of the volume before mounting it in the final destination.

You can enable this initContainer by setting volumePermissions.enabled to true.

Upgrading

It's necessary to set the rootUser.password parameter when upgrading for readiness/liveness probes to work properly. When you install this chart for the first time, some notes will be displayed providing the credentials you must use under the 'Administrator credentials' section. Please note down the password and run the command below to upgrade your chart:

bash
$ helm upgrade my-release stable/mariadb --set rootUser.password=[ROOT_PASSWORD]

| Note: you need to substitute the placeholder [ROOT_PASSWORD] with the value obtained in the installation notes.

To 7.0.0

Helm performs a lookup for the object based on its group (apps), version (v1), and kind (Deployment). Also known as its GroupVersionKind, or GVK. Changing the GVK is considered a compatibility breaker from Kubernetes' point of view, so you cannot "upgrade" those objects to the new GVK in-place. Earlier versions of Helm 3 did not perform the lookup correctly which has since been fixed to match the spec.

In https://github.com/helm/charts/pull/17308 the apiVersion of the statefulset resources was updated to apps/v1 in tune with the api's deprecated, resulting in compatibility breakage.

This major version bump signifies this change.

To 6.0.0

MariaDB version was updated from 10.1 to 10.3, there are no changes in the chart itself. According to the official documentation, upgrading from 10.1 should be painless. However, there are some things that have changed which could affect an upgrade:

To 5.0.0

Backwards compatibility is not guaranteed unless you modify the labels used on the chart's deployments. Use the workaround below to upgrade from versions previous to 5.0.0. The following example assumes that the release name is mariadb:

console
$ kubectl delete statefulset opencart-mariadb --cascade=false