Skip to content

Commit

Permalink
Merge pull request #184 from chrislinan/issue#7731
Browse files Browse the repository at this point in the history
issue#7731: add endpoint for GCP objectstore client
  • Loading branch information
sseago authored Oct 28, 2024
2 parents 53916eb + 5e50d5a commit 5c34921
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
17 changes: 11 additions & 6 deletions backupstoragelocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand All @@ -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
```
7 changes: 7 additions & 0 deletions velero-plugin-for-gcp/object_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -101,6 +102,7 @@ func (o *ObjectStore) Init(config map[string]string) error {
kmsKeyNameConfigKey,
serviceAccountConfig,
credentialsFileConfigKey,
storeEndpointConfigKey,
); err != nil {
return err
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5c34921

Please sign in to comment.