Orange-OpenSource / galera-operator

Galera Operator automates tasks for managing a Galera cluster in Kubernetes
Apache License 2.0
34 stars 18 forks source link

Clone with restoring #9

Open ldangeard-orange opened 4 years ago

ldangeard-orange commented 4 years ago

If you want to restore galera cluster backup on a new galera cluster, you need to rename backup on S3 before deploy. It's not possible to use an existing backup, no error in log

<old name of galera cluster>-galera-backup.YYYYMMDDHHMMSS.sql.gz
<new name of galera cluster>-galera-backup.YYYYMMDDHHMMSS.sql.gz
apiVersion: sql.databases/v1beta2
kind: Galera
metadata:
  name: <new name of galera cluster>
...
spec:
  replicas: 3
  restore:
    name: <new name of galera cluster>-galera-backup.YYYYMMDDHHMMSS.sql.gz

other points, if you make a mistake on the s3 address or on the bucket name, there is no error in the operator logs

sebs42 commented 4 years ago

There is two things

First is about the logs, today, logs are just written by backup container and not the Galera container, It will be better to centralize this information (bad url, bad creds, ...) on the operator level, so the backup swagger need to be edited.

The second thing is more obscur, you wrote you cannot restore if you don't change the name of the backup ? I cannot reproduce the problem, can you provide more information with full yaml (first Galera, GaleraBackup and second Galera)

ldangeard-orange commented 4 years ago

Hi full yaml (first Galera, GaleraBackup and second Galera)

apiVersion: sql.databases/v1beta2
kind: Galera
metadata:
  name: lologal
  namespace: pierre
  ## Adding this annotation make this cluster managed by clusterwide operators
  ## namespaced operators ignore it
  #annotations:
  #  sql.databases/scope: clusterwide
  labels:
    stage: dev
    owner: sebs42
    metric-ident: pla
    galera-cluster: lologal
spec:
  replicas: 3
  pod:
    credentialsSecret:
      name: galera-secret
    image: sebs42/mariadb:10.4.2-bionic
    mycnfConfigMap:
      name: galeraconflaurentv2
    resources:
      requests:
        cpu: 500m
        memory: 2Gi
      limits:
        cpu: 1000m
        memory: 4Gi
    env:
      - name: MYSQL_ROOT_PASSWORD
        valueFrom:
          secretKeyRef:
            name: galera-secret
            key: password
      - name: EXPORTER_PASSWORD
        valueFrom:
          secretKeyRef:
            name: galera-secret
            key: exporter-password
    metric:
      image: prom/mysqld-exporter:v0.12.1
      env:
        - name: DATA_SOURCE_NAME
          valueFrom:
            secretKeyRef:
              name: galera-secret
              key: exporter-connexion
      resources:
        requests:
          cpu: 100m
          memory: 1Gi
        limits:
          cpu: 110m
          memory: 2Gi
      port: 9104
    priorityClassName: database-priority
    affinity:
      podAntiAffinity:
        requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
                - key: galera-cluster
                  operator: In
                  values:
                    - lologal
            topologyKey: kubernetes.io/hostname
  persistentVolumeClaimSpec:
    accessModes: [ "ReadWriteOnce" ]
    resources:
      requests:
        storage: 5Gi
apiVersion: sql.databases/v1beta2
kind: GaleraBackup
metadata:
  name: galera-backup
  namespace: pierre
spec:
  galeraName: lologal
  backupMethodType: mariabackup
  mariabackup:
    credentialsBackup:
      name: galera-secret
  storageProviderType: S3
  s3:
#    region:
    endpoint: http://minio.cl1.k8s.dbsp.dw
    bucket: galerabackup
    credentialsSecret:
      name: s3-secret
NAME            TIMESTARTED   TIMECOMPLETED   LOCATION                                      METHOD        PROVIDER
galera-backup                 3d1h            lologal-galera-backup.20200707130435.sql.gz   mariabackup   S3

if we change

  restore:
    name: lologal-galera-backup.20200707130435.sql.gz

by

  restore:
    name: loloclone-galera-backup.20200707130435.sql.gz

and ducplicate backup in S3, cluster loloclone is up