mysqldump

by Kokuwa.io

Helm chartv7.0.3App v3.2.19

A Helm chart to help backup MySQL databases using mysqldump

About this chart

mysqldump

mysqldump is a tool for creating backups of MySQL databases in the form of a .sql file.

TLDR

helm repo add kokuwa https://kokuwaio.github.io/helm-charts
helm install kokuwa/mysqldump --set mysql.host=mysql;mysql.username=root,mysql.password=password

Introduction

This chart helps set up a cronjob or one time job to backup a MySQL database with mysqldump into a Persistent Volume. You can specify an existing PVC, or helm will create one for you.

Prerequisites

  • Kubernetes 1.21
  • Helm 3.0

Installing the Chart

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

helm install kokuwa/mysqldump --set mysql.host=mysql,mysql.username=root,mysql.password=password

This command will create a cronjob to run a job once a day to backup the databases found on the host mysql

Tip: List all releases using helm list

Uninstalling the Chart

To uninstall/delete the my-release deployment:

helm uninstall my-release

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

Configuration

The following tables lists the configurable parameters of the mysqldump chart and their default values.

ParameterDescriptionDefault
image.registryName of docker registry to usequay.io
image.repositoryName of image to usemonotek/gcloud-mysql
image.tagVersion of image to use (uses appVersion form Chart.yaml as default if not set)""
image.pullPolicyPull Policy to use for imageIfNotPresent
mysql.dbMySQL db(s) to backup (optional)mysql
mysql.hostMySQL host to backupmysql
mysql.usernameMySQL usernameroot
mysql.passwordMySQL password""
mysql.existingSecretexisting secret name, used to get MySQL password (if set)
mysql.existingSecretKeyexisting secret keymysql-root-password
mysql.portMySQL port3306
mysql.dumpOptionsoptions to pass onto MySQL dump"--opt --single-transaction"
schedulecrontab schedule to run on. set as now to run as a one time job"0 3 * * *"
rsync.optionsoptions to pass onto rsync"-av"
debugprint some extra debug logs during backupfalse
additionalStepsrun these extra shell steps after all backup jobs completed[]
successfulJobsHistoryLimitnumber of successful jobs to remember1
failedJobsHistoryLimitnumber of failed jobs to remember1
sshMountpathUser's path (used to mount SSH key if needed)"/home/cloudsdk"
persistentVolumeClaimexisting Persistent Volume Claim to backup to, leave blank to create a new one
persistence.enabledcreate new PVC (unless persistentVolumeClaim is set)true
persistence.sizesize of PVC to create8Gi
persistence.accessModeaccessMode to use for PVCReadWriteOnce
persistence.storageClassstorage class to use for PVC
persistence.subPathsubPath for PVC
housekeeping.enableddelete olf backups in pvctrue
housekeeping.keepDayskeep last x days of backups in PVC10
upload.googlestoragebucket.enabledupload backups to google storagefalse
upload.googlestoragebucket.bucketnamegoogle storage addressgs://mybucket/test
upload.googlestoragebucket.jsonKeyfilejson keyfile for serviceaccount""
upload.googlestoragebucket.existingSecretspecify a secretname to usenil
upload.googlestoragebucket.usingGCPControllerenable the use of the GCP Service Account Controllerfalse
upload.googlestoragebucket.serviceAccountNamespecify a service account name to usenil
upload.ssh.enabledupload backups via SSHfalse
upload.ssh.existingSecretspecify a secretname to usenil
upload.ssh.userSSH userbackup
upload.ssh.hostSSH server URLyourdomain.com
upload.ssh.dirSSH directory on server/backup
upload.ssh.privatekeySSH user private key""
upload.openstack.enabledupload backups via swift to openstackfalse
upload.openstack.userusernamebackup@mydomain
upload.openstack.userDomainuser-domaindefault
upload.openstack.passwordpassword, overridden by existingSecret/existingSecretKey if set
upload.openstack.authUrlopenstack auth URL (v3)https://mydomain:5000/v3
upload.openstack.projectproject namemy_project
upload.openstack.projectDomainproject domaindefault
upload.openstack.destinationdestination path, starting witch containerbackup/mysql
upload.openstack.existingSecretoptional, specify a secret name to use for password
upload.openstack.existingSecretKeyoptional, specify a secret key to use for passwordopenstack-backup-password
upload.openstack.ttlDaysdays to set time-to-live on uploaded objects (0 to disable)30
upload.s3.enabledupload backups to s3 storagefalse
upload.s3.bucketnames3 bucket namemysql-backup
upload.s3.endpointURL endpoint of the S3 servicehttps://mydomain.com
upload.s3.regionAWS region to useus-east-1
upload.s3.accesskeys3 access key""
upload.s3.secretkeys3 secret key""
upload.s3.existingSecretoptional, existing secret name, used to get s3 Secret key (if set)""
upload.s3.existingSecretKeyoptional, specify a secret key to use for s3 Secret keyS3_SECRET_KEY
resourcesresource definitions{}
nodeSelectork8s-node selector{}
tolerationstolerations[]
affinityaffinity{}
securityContext.enabledset true to change default security context of job/cronjobfalse
securityContext.fsGroupgroup ID to use999
securityContext.runAsUseruser ID to use999

Auto generating the gcp service account

By enabling the flag upload.googlestoragebucket.usingGCPController and having a GCP Service Account Controller deployed in your cluster, it is possible to autogenerate and inject the service account used for the storage bucket access. For more information see https://github.com/kiwigrid/helm-charts/tree/master/charts/gcp-serviceaccount-controller

helm install kokuwa/mysqldump --name my-release --set persistentVolumeClaim=name-of-existing-pvc

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

helm install kokuwa/mysqldump --name my-release -f values.yaml

Deploy mysqldump with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has mysqldump on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartmysqldump is pinned at v7.0.3 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply