bitpoke / mysql-operator

Asynchronous MySQL Replication on Kubernetes using Percona Server and Openark's Orchestrator.
https://www.bitpoke.io/docs/mysql-operator/getting-started/
Apache License 2.0
1.04k stars 275 forks source link

Restore a running mysql cluster #390

Closed cpanato closed 5 years ago

cpanato commented 5 years ago

Hello I did the following thing: 1- create a mysql cluster without a database using this sample manifest

apiVersion: mysql.presslabs.org/v1alpha1
kind: MysqlCluster
metadata:
  name: mm1
spec:
  replicas: 1
  secretName: test
  volumeSpec:
    persistentVolumeClaim:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 10Gi

2- wait for the the pod be healthy 3- updated the manifest to use a backup and apply the restore

apiVersion: mysql.presslabs.org/v1alpha1
kind: MysqlCluster
metadata:
  name: mm1
spec:
  replicas: 1
  secretName: test

  initBucketURL: s3://xxxxoooooxxxxooooo/backup11.gz
  initBucketSecretName: test-restore
  volumeSpec:
    persistentVolumeClaim:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 10Gi

I saw the pos was in terminating state and then it start a new one, however the backup was not applied.

Does this is possible to achieve?

cc @AMecea

cpanato commented 5 years ago

saw this: https://github.com/presslabs/mysql-operator/blob/103e6a9db5ce9de6c7017f24c5f0f6cb43cf4349/pkg/sidecar/appclone.go#L30

i tried to remove but then the pod never came up

AMecea commented 5 years ago

Hi @cpanato,

To init a cluster from a backup you have to set initBucketURL from the first time (when the cluster is created). The initBucketURL is used only when the disk empty.

In your case, you can delete the PVC and wait for pod to be recreated (maybe scale to 0 then remove the PVC then scale back to 1)

cpanato commented 5 years ago

@AMecea I will try that. will be a good addition if we have a controller that apply a restore

cpanato commented 5 years ago

thanks that worked :)