Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support backup to gcs #1127

Merged
merged 7 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions images/backup-manager/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ region = ${AWS_REGION}
acl = ${AWS_ACL}
endpoint = ${S3_ENDPOINT}
storage_class = ${AWS_STORAGE_CLASS}
[gs]
[gcs]
type = google cloud storage
project_number = ${GCS_PROJECT_ID}
service_account_file = /tmp/google-credentials.json
object_acl = ${GCS_OBJECT_ACL}
bucket_acl = ${GCS_BUCKET_ACL}
location = ${GCS_LOCATION}
storage_class = ${GCS_STORAGE_CLASS:-"MULTI_REGIONAL"}
storage_class = ${GCS_STORAGE_CLASS:-"COLDLINE"}
[azure]
type = azureblob
account = ${AZUREBLOB_ACCOUNT}
Expand Down
15 changes: 15 additions & 0 deletions manifests/backup/backup-gcs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: pingcap.com/v1alpha1
kind: Backup
metadata:
name: demo1-backup-gcs
namespace: test1
spec:
gcs:
projectId: <your-project-id>
secretName: gcs-secret
storageType: gcs
cluster: demo1
tidbSecretName: backup-demo1-tidb-secret
storageClassName: local-storage
storageSize: 1Gi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: pingcap.com/v1alpha1
kind: Backup
metadata:
name: demo1-backup
name: demo1-backup-s3
namespace: test1
spec:
s3:
Expand All @@ -12,5 +12,5 @@ spec:
storageType: s3
cluster: demo1
tidbSecretName: backup-demo1-tidb-secret
storageClassName: rook-ceph-block
storageClassName: local-storage
storageSize: 1Gi
21 changes: 21 additions & 0 deletions manifests/backup/backup-schedule-gcs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
apiVersion: pingcap.com/v1alpha1
kind: BackupSchedule
metadata:
name: demo1-backup-schedule-gcs
namespace: test1
spec:
#maxBackups: 5
#pause: true
maxReservedTime: "3h"
storageClassName: local-storage
storageSize: 10Gi
schedule: "*/2 * * * *"
backupTemplate:
gcs:
#location: us-east-1
secretName: gcs-secret
projectId: <your-project-id>
storageType: gcs
cluster: demo1
tidbSecretName: backup-demo1-tidb-secret
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
apiVersion: pingcap.com/v1alpha1
kind: BackupSchedule
metadata:
name: demo1-backup-schedule
name: demo1-backup-schedule-s3
namespace: test1
spec:
#maxBackups: 5
#pause: true
maxReservedTime: "3h"
storageClassName: rook-ceph-block
storageClassName: local-storage
storageSize: 10Gi
schedule: "*/2 * * * *"
backupTemplate:
Expand Down
76 changes: 70 additions & 6 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,39 @@ spec:
cluster:
description: Cluster is the Cluster to backup.
type: string
gcs:
description: GcsStorageProvider represents the google cloud storage
for storing backups.
properties:
bucket:
description: Bucket in which to store the Backup.
type: string
bucket_acl:
description: BucketAcl represents the access control list for new
buckets
type: string
location:
description: Location in which the gcs bucket is located.
type: string
object_acl:
description: ObjectAcl represents the access control list for new
objects
type: string
projectId:
description: ProjectId represents the project that organizes all
your Google Cloud Platform resources
type: string
secretName:
description: SecretName is the name of secret which stores the gcs
service account credentials JSON .
type: string
storageClass:
description: StorageClass represents the storage class
type: string
required:
- projectId
- secretName
type: object
s3:
description: S3StorageProvider represents a S3 compliant storage for
storing backups.
Expand All @@ -231,8 +264,8 @@ spec:
description: Region in which the S3 compatible bucket is located.
type: string
secretName:
description: SecretName is the name of secret which stores ceph
object store access key and secret key.
description: SecretName is the name of secret which stores S3 compliant
storage access key and secret key.
type: string
storageClass:
description: StorageClass represents the storage class
Expand All @@ -259,7 +292,6 @@ spec:
- cluster
- tidbSecretName
- storageType
- s3
- storageClassName
- storageSize
type: object
Expand Down Expand Up @@ -401,6 +433,39 @@ spec:
cluster:
description: Cluster is the Cluster to backup.
type: string
gcs:
description: GcsStorageProvider represents the google cloud storage
for storing backups.
properties:
bucket:
description: Bucket in which to store the Backup.
type: string
bucket_acl:
description: BucketAcl represents the access control list for
new buckets
type: string
location:
description: Location in which the gcs bucket is located.
type: string
object_acl:
description: ObjectAcl represents the access control list for
new objects
type: string
projectId:
description: ProjectId represents the project that organizes
all your Google Cloud Platform resources
type: string
secretName:
description: SecretName is the name of secret which stores the
gcs service account credentials JSON .
type: string
storageClass:
description: StorageClass represents the storage class
type: string
required:
- projectId
- secretName
type: object
s3:
description: S3StorageProvider represents a S3 compliant storage
for storing backups.
Expand All @@ -423,8 +488,8 @@ spec:
description: Region in which the S3 compatible bucket is located.
type: string
secretName:
description: SecretName is the name of secret which stores ceph
object store access key and secret key.
description: SecretName is the name of secret which stores S3
compliant storage access key and secret key.
type: string
storageClass:
description: StorageClass represents the storage class
Expand Down Expand Up @@ -452,7 +517,6 @@ spec:
- cluster
- tidbSecretName
- storageType
- s3
- storageClassName
- storageSize
type: object
Expand Down
83 changes: 78 additions & 5 deletions pkg/apis/pingcap/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 26 additions & 2 deletions pkg/apis/pingcap/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ type BackupStorageType string
const (
// BackupStorageTypeS3 represents all storage that compatible with the Amazon S3.
BackupStorageTypeS3 BackupStorageType = "s3"

// BackupStorageTypeGcs represents the google cloud storage
BackupStorageTypeGcs BackupStorageType = "gcs"
)

// +k8s:openapi-gen=true
Expand All @@ -341,7 +344,8 @@ const (
// +k8s:openapi-gen=true
// StorageProvider defines the configuration for storing a backup in backend storage.
type StorageProvider struct {
S3 *S3StorageProvider `json:"s3"`
S3 *S3StorageProvider `json:"s3,omitempty"`
Gcs *GcsStorageProvider `json:"gcs,omitempty"`
}

// +k8s:openapi-gen=true
Expand All @@ -360,7 +364,27 @@ type S3StorageProvider struct {
// Acl represents access control permissions for this bucket
Acl string `json:"acl,omitempty"`
// SecretName is the name of secret which stores
// ceph object store access key and secret key.
// S3 compliant storage access key and secret key.
SecretName string `json:"secretName"`
}

// +k8s:openapi-gen=true
// GcsStorageProvider represents the google cloud storage for storing backups.
type GcsStorageProvider struct {
// ProjectId represents the project that organizes all your Google Cloud Platform resources
ProjectId string `json:"projectId"`
// Location in which the gcs bucket is located.
Location string `json:"location,omitempty"`
// Bucket in which to store the Backup.
Bucket string `json:"bucket,omitempty"`
// StorageClass represents the storage class
StorageClass string `json:"storageClass,omitempty"`
// ObjectAcl represents the access control list for new objects
ObjectAcl string `json:"object_acl,omitempty"`
// BucketAcl represents the access control list for new buckets
BucketAcl string `json:"bucket_acl,omitempty"`
// SecretName is the name of secret which stores the
// gcs service account credentials JSON .
SecretName string `json:"secretName"`
}

Expand Down
Loading