mysqldump

by joaquinito2051

Helm chartv2.4.0App 2.4.0

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.

TL;DR;

$ helm install <helm-repo>/mysqldump \
  --set mysql.host=mysql;mysql.username=root,mysql.password=password,persistence.enabled=true

$ helm install stable/mysqldump \

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.8

Installing the Chart

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

$ helm install <helm-repo>/mysqldump \
  --set mysql.host=mysql,mysql.username=root,mysql.password=password,persistence.enabled=true

$ helm install stable/mysqldump \

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 delete 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.repositoryName of image to usemonotek/gcloud-mysql
image.tagVersion of image to use"6"
image.pullPolicyPull Policy to use for imageIfNotPresent
mysql.dbsingle mysql db to backup (optional)mysql
mysql.hostmysql host to backupmysql
mysql.usernamemysql usernameroot
mysql.passwordmysql password""
mysql.portmysql port3306
schedulecrontab schedule to run on. set as now to run as a one time job"0/5 * * * *"
optionsoptions to pass onto MySQL"--opt --single-transaction"
debugprint some extra debug logs during backupfalse
additionalStepsrun these extra shell steps after all backup jobs completed[]
successfulJobsHistoryLimitnumber of successful jobs to remember5
failedJobsHistoryLimitnumber of failed jobs to remember5
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.reclaimPolicyused PV reclaim policy"delete"
persistence.subPathsubPath for PVC
allDatabases.enabledbackup all databasestrue
allDatabases.SingleSqlFilebackup all databases to singel filefalse
housekeeping.enableddelete olf backups in pvctrue
housekeeping.keepDayskeep last x days of backups in PVC10
saveToDirectorysaves the sql backup to a directory named like the database or alldatabasesfalse
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.userssh userbackup
upload.ssh.hostssh server urlyourdomain.com
upload.ssh.dirdirectory on server/backup
upload.ssh.privatekeyssh user private key""
resourcesresource definitions{}
nodeSelectornode selector{}
tolerationstolerations[]
affinityaffinity{}

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 <helm-repo>/mysqldump --name my-release \
    --set persistentVolumeClaim=name-of-existing-pvc

$ helm install stable/mysqldump --name my-release \

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

$ helm install <helm-repo>/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 v2.4.0 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