Install the operator named test
:
helm install test charts/mysql-operator
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 |
kubectl apply -f config/samples/mysql_v1alpha1_mysqlcluster.yaml
After run cluster success
kubectl apply -f config/samples/mysql_v1alpha1_backup.yaml
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
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.
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
make manifests
make install
make deploy IMG=acekingke/controller:0.1 KUSTOMIZE=~/radondb-mysql-kubernetes/bin/kustomize