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

issue#7731: add endpoint for GCP objectstore client #184

Merged
merged 6 commits into from
Oct 28, 2024
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
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
Loading