Skip to content

Latest commit

 

History

History
127 lines (105 loc) · 2.67 KB

deploy_backup_restore_s3.md

File metadata and controls

127 lines (105 loc) · 2.67 KB

mysql-operator

Quickstart for backup

Install the operator named test:

helm install test charts/mysql-operator

configure backup

add the secret file

kind: Secret
apiVersion: v1
metadata:
  name: sample-backup-secret
  namespace: default
data:
  s3-endpoint: aHR0cDovL3MzLnNoMWEucWluZ3N0b3IuY29t
  s3-access-key: SEdKWldXVllLSENISllFRERKSUc=
  s3-secret-key: TU44TkNUdDJLdHlZREROTTc5cTNwdkxtNTlteE01blRaZlRQMWxoag==
  s3-bucket: bGFsYS1teXNxbA==
type: Opaque

s3-xxxx value is encode by base64, you can get like that

echo -n "hello"|base64

then, create the secret in k8s.

kubectl create -f config/samples/backup_secret.yaml

Please add the backupSecretName in mysql_v1apha1_mysqlcluster.yaml, name as secret file:

spec:
  replicas: 3
  mysqlVersion: "5.7"
  backupSecretName: sample-backup-secret
  ...

now create backup yaml file mysql_v1apha1_backup.yaml like this:

apiVersion: mysql.radondb.com/v1alpha1
kind: Backup
metadata:
  name: backup-sample1
spec:
  # Add fields here
  hostname: sample-mysql-0
  clustname: sample
name function
hostname pod name in cluser
clustname cluster name

start cluster

kubectl apply -f config/samples/mysql_v1alpha1_mysqlcluster.yaml     

start backup

After run cluster success

kubectl apply -f config/samples/mysql_v1alpha1_backup.yaml

Uninstall

Uninstall the cluster named sample:

kubectl delete mysqlclusters.mysql.radondb.com sample

Uninstall the operator name test:

helm uninstall test
kubectl delete -f config/samples/mysql_v1alpha1_backup.yaml

Uninstall the crd:

kubectl delete customresourcedefinitions.apiextensions.k8s.io mysqlclusters.mysql.radondb.com

restore cluster from backup copy

check your s3 bucket, get the directory where your backup to, such as backup_2021720827. add it to RestoreFrom in yaml file

...
spec:
  replicas: 3
  mysqlVersion: "5.7"
  backupSecretName: sample-backup-secret
  restoreFrom: "backup_2021720827"
...

Then you use:

kubectl apply -f config/samples/mysql_v1alpha1_mysqlcluster.yaml     

could restore a cluster from the backup_2021720827 copy in the S3 bucket.

build your own image

such as :

docker build -f Dockerfile.sidecar -t  acekingke/sidecar:0.1 . && docker push acekingke/sidecar:0.1
docker build -t acekingke/controller:0.1 . && docker push acekingke/controller:0.1

you can replace acekingke/sidecar:0.1 with your own tag

deploy your own manager

make manifests
make install 
make deploy  IMG=acekingke/controller:0.1 KUSTOMIZE=~/radondb-mysql-kubernetes/bin/kustomize