diff --git a/backupstoragelocation.md b/backupstoragelocation.md index f8614bd..9403f9c 100644 --- a/backupstoragelocation.md +++ b/backupstoragelocation.md @@ -13,27 +13,27 @@ spec: # # Required. provider: velero.io/gcp - + objectStorage: # The bucket in which to store backups. # # Required. bucket: my-bucket - + # The prefix within the bucket under which to store backups. # # Optional. prefix: my-prefix - + config: - # Name of the Cloud KMS key to use to encrypt backups stored in this location, in the form - # "projects/P/locations/L/keyRings/R/cryptoKeys/K". See customer-managed Cloud KMS keys + # Name of the Cloud KMS key to use to encrypt backups stored in this location, in the form + # "projects/P/locations/L/keyRings/R/cryptoKeys/K". See customer-managed Cloud KMS keys # (https://cloud.google.com/storage/docs/encryption/using-customer-managed-keys) for details. # # Optional. kmsKeyName: projects/my-project/locations/my-location/keyRings/my-keyring/cryptoKeys/my-key - # Name of the GCP service account to use for this backup storage location. Specify the + # Name of the GCP service account to use for this backup storage location. Specify the # service account here if you want to use workload identity instead of providing the key file. # # Optional (defaults to "false"). @@ -43,4 +43,9 @@ spec: # # Optional. credentialsFile: path/to/my/credential + + # Configuration of storage endpoint for GCS bucket + # + # Optional. + storeEndpoint: storage-example.p.googleapis.com ``` diff --git a/velero-plugin-for-gcp/object_store.go b/velero-plugin-for-gcp/object_store.go index 1cdf37a..87749df 100644 --- a/velero-plugin-for-gcp/object_store.go +++ b/velero-plugin-for-gcp/object_store.go @@ -39,6 +39,7 @@ const ( kmsKeyNameConfigKey = "kmsKeyName" serviceAccountConfig = "serviceAccount" credentialsFileConfigKey = "credentialsFile" + storeEndpointConfigKey = "storeEndpoint" ) // bucketWriter wraps the GCP SDK functions for accessing object store so they can be faked for testing. @@ -101,6 +102,7 @@ func (o *ObjectStore) Init(config map[string]string) error { kmsKeyNameConfigKey, serviceAccountConfig, credentialsFileConfigKey, + storeEndpointConfigKey, ); err != nil { return err } @@ -139,6 +141,11 @@ func (o *ObjectStore) Init(config map[string]string) error { return errors.WithStack(err) } + // if using a endpoint, we need to pass it when creating the object store client + if endpoint, ok := config[storeEndpointConfigKey]; ok { + clientOptions = append(clientOptions, option.WithEndpoint(endpoint)) + } + if creds.JSON != nil { o.fileCredType, err = getSecretAccountTypeKey(creds.JSON) if err != nil {