Skip to content

Commit

Permalink
Rename initBackupURI into initBackupURL and update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AMecea committed May 10, 2019
1 parent d909ab9 commit a3c6556
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 17 deletions.
4 changes: 2 additions & 2 deletions config/crds/mysql_v1alpha1_mysqlcluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ spec:
type: string
initBucketSecretName:
type: string
initBucketURI:
description: A bucket URI that contains a xtrabackup to initialize the
initBucketURL:
description: A bucket URL that contains a xtrabackup to initialize the
mysql database.
type: string
maxSlaveLatency:
Expand Down
8 changes: 4 additions & 4 deletions docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Backups are stored on object storage services like S3 or Google Cloud Storage. I

### Setup a backup on S3

You need to specify the `backupBucketUri` for the cluster to an URI like `s3://BUCKET_NAME`, and a secret.
You need to specify the `backupURL` for the cluster to an URL like `s3://BUCKET_NAME/cluster-name/`, and a secret.

```yaml
apiVersion: v1
Expand Down Expand Up @@ -185,8 +185,8 @@ Run the following command:
kubectl apply -f example-backup.yaml
```

You need to specify the `backupBucketUri` for the corresponding cluster to an URI like
`gs://BUCKET_NAME` and `backupSecretName`. Open the file named `example-cluster.yaml` and copy it into
You need to specify the `backupURL` for the corresponding cluster to an URL like
`gs://BUCKET_NAME/` and `backupSecretName`. Open the file named `example-cluster.yaml` and copy it into
the following YAML code:

```yaml
Expand All @@ -198,7 +198,7 @@ spec:
replicas: 2
secretName: my-secret
backupSecretName: my-cluster-backup-secret
backupUri: gs://pl-test-mysql-operator/
backupURL: gs://pl-test-mysql-operator/
```

Then run the following command:
Expand Down
6 changes: 3 additions & 3 deletions docs/cluster-recover.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ aliases: []
toc: true
---

The MySQL operator provides a way to recreate a cluster based on a backup (snapshot). Just create a new cluster with a new name which has `initBucketURI` field pointed to the right backup.
The MySQL operator provides a way to recreate a cluster based on a backup (snapshot). Just create a new cluster with a new name which has `initBucketURL` field pointed to the right backup.

## Initialize a cluster from a backup

To initialize a new cluster from a backup just set the `initBucketURI` to the backup that you want to use. The credentails for connecting to the storage provider should be set in the secret specified in the `initBucketSecretName` field , the same as for `backupSecretName` presented in the [Backup]({{< ref "./backups.md" >}}) section. These fields can point to the same secret.
To initialize a new cluster from a backup just set the `initBucketURL` to the backup that you want to use. The credentails for connecting to the storage provider should be set in the secret specified in the `initBucketSecretName` field , the same as for `backupSecretName` presented in the [Backup]({{< ref "./backups.md" >}}) section. These fields can point to the same secret.


``` yaml
Expand All @@ -28,7 +28,7 @@ metadata:
spec:
secretName: the-secret

initBucketURI: gs://bucket_name/path/to/backup.xbackup.gz
initBucketURL: gs://bucket_name/path/to/backup.xbackup.gz
initBucketSecretName: backup-secret
```

Expand Down
1 change: 1 addition & 0 deletions examples/example-backup-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ data:
# GCS_LOCATION: ?
# GCS_STORAGE_CLASS: MULTI_REGIONAL

# only for read-only purpose
# HTTP_URL: ?

# AZUREBLOB_ACCOUNT: ?
Expand Down
4 changes: 2 additions & 2 deletions examples/example-cluster-init.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ spec:
secretName: the-secret

backupSchedule: "1 1 * * *"
backupUri: gs://bucket_name/path/
backupURL: gs://bucket_name/path/
backupSecretName: backup-secret

initBucketURI: gs://bucket_name/path/to/backup.xbackup.gz
initBucketURL: gs://bucket_name/path/to/backup.xbackup.gz
initBucketSecretName: backup-secret
2 changes: 1 addition & 1 deletion examples/example-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spec:
replicas: 2
secretName: my-secret
# mysqlVersion: 5.7
# initBucketURI: gs://bucket_name/backup.xtrabackup.gz
# initBucketURL: gs://bucket_name/backup.xtrabackup.gz
# initBucketSecretName:

## PodDisruptionBudget
Expand Down
5 changes: 4 additions & 1 deletion pkg/apis/mysql/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ type MysqlClusterSpec struct {
// +optional
Image string `json:"image,omitempty"`

// A bucket URI that contains a xtrabackup to initialize the mysql database.
// A bucket URL that contains a xtrabackup to initialize the mysql database.
// +optional
InitBucketURL string `json:"initBucketURL,omitempty"`
// Same as InitBucketURL but is DEPRECATED
// +optional
InitBucketURI string `json:"initBucketURI,omitempty"`
InitBucketSecretName string `json:"initBucketSecretName,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/mysqlcluster/internal/syncer/statefullset.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ func (s *sfsSyncer) getEnvFor(name string) []core.EnvVar {
Value: s.opt.OrchestratorURI,
})

if len(s.cluster.Spec.InitBucketURI) > 0 && name == containerCloneName {
if len(s.cluster.Spec.InitBucketURL) > 0 && name == containerCloneName {
env = append(env, core.EnvVar{
Name: "INIT_BUCKET_URI",
Value: s.cluster.Spec.InitBucketURI,
Value: s.cluster.Spec.InitBucketURL,
})
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/internal/mysqlcluster/mysqlcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,8 @@ func (c *MysqlCluster) GetMysqlImage() string {

// UpdateSpec updates the cluster specs that need to be saved
func (c *MysqlCluster) UpdateSpec() {
// nothing to do
// TODO: remove this in next major release
if len(c.Spec.InitBucketURL) == 0 {
c.Spec.InitBucketURL = c.Spec.InitBucketURI
}
}
2 changes: 1 addition & 1 deletion test/e2e/backups/backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ var _ = Describe("Mysql backups tests", func() {
// create cluster
cl := framework.NewCluster(name, f.Namespace.Name)
cl.Spec.InitBucketSecretName = backupSecret.Name
cl.Spec.InitBucketURI = backup.Spec.BackupURL
cl.Spec.InitBucketURL = backup.Spec.BackupURL
Expect(f.Client.Create(context.TODO(), cl)).To(Succeed(),
"failed to create cluster '%s'", cluster.Name)

Expand Down

0 comments on commit a3c6556

Please sign in to comment.