Skip to content

Commit e940723

Browse files
committed
K8SPSMDB-1602: address review comments
1 parent 5695fc4 commit e940723

7 files changed

Lines changed: 33 additions & 39 deletions

config/crd/bases/psmdb.percona.com_perconaservermongodbbackups.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ spec:
139139
- backoffMax
140140
- backoffMultiplier
141141
type: object
142+
workloadIdentity:
143+
type: boolean
142144
required:
143145
- bucket
144-
- credentialsSecret
145146
type: object
146147
lastTransition:
147148
format: date-time

config/crd/bases/psmdb.percona.com_perconaservermongodbrestores.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ spec:
9797
- backoffMax
9898
- backoffMultiplier
9999
type: object
100+
workloadIdentity:
101+
type: boolean
100102
required:
101103
- bucket
102-
- credentialsSecret
103104
type: object
104105
lastTransition:
105106
format: date-time

config/crd/bases/psmdb.percona.com_perconaservermongodbs.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,10 @@ spec:
361361
- backoffMax
362362
- backoffMultiplier
363363
type: object
364+
workloadIdentity:
365+
type: boolean
364366
required:
365367
- bucket
366-
- credentialsSecret
367368
type: object
368369
main:
369370
type: boolean

pkg/apis/psmdb/v1/psmdb_types.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,19 +1290,12 @@ type GCSRetryer struct {
12901290
}
12911291

12921292
type BackupStorageGCSSpec struct {
1293-
Bucket string `json:"bucket"`
1294-
Prefix string `json:"prefix,omitempty"`
1295-
CredentialsSecret string `json:"credentialsSecret,omitempty"`
1296-
Credentials *GCSCredentials `json:"credentials,omitempty"`
1297-
ChunkSize int `json:"chunkSize,omitempty"`
1298-
Retryer *GCSRetryer `json:"retryer,omitempty"`
1299-
}
1300-
1301-
// GCSCredentials configures how PBM authenticates with GCS.
1302-
// When WorkloadIdentity is true, PBM uses Application Default Credentials (ADC)
1303-
// provided by GKE Workload Identity instead of a credentialsSecret.
1304-
type GCSCredentials struct {
1305-
WorkloadIdentity bool `json:"workloadIdentity,omitempty"`
1293+
Bucket string `json:"bucket"`
1294+
Prefix string `json:"prefix,omitempty"`
1295+
CredentialsSecret string `json:"credentialsSecret,omitempty"`
1296+
WorkloadIdentity bool `json:"workloadIdentity,omitempty"`
1297+
ChunkSize int `json:"chunkSize,omitempty"`
1298+
Retryer *GCSRetryer `json:"retryer,omitempty"`
13061299
}
13071300

13081301
type BackupStorageAzureSpec struct {

pkg/apis/psmdb/v1/zz_generated.deepcopy.go

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/psmdb/backup/pbm.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,7 @@ func GetPBMStorageGCSConfig(
507507

508508
// When WorkloadIdentity is enabled, skip credential secret loading entirely.
509509
// PBM will use Application Default Credentials (ADC) provided by GKE Workload Identity.
510-
useWorkloadIdentity := stg.GCS.Credentials != nil && stg.GCS.Credentials.WorkloadIdentity
511-
512-
if !useWorkloadIdentity && stg.GCS.CredentialsSecret != "" {
510+
if !stg.GCS.WorkloadIdentity && stg.GCS.CredentialsSecret != "" {
513511
gcsSecret, err := getSecret(ctx, k8sclient, cluster.Namespace, stg.GCS.CredentialsSecret)
514512
if err != nil {
515513
return config.StorageConf{}, errors.Wrap(err, "get GCS credentials secret")

pkg/psmdb/backup/pbm_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,26 @@ func TestPBMStorageConfig(t *testing.T) {
346346
},
347347
},
348348
},
349+
"gcs workload identity": {
350+
[]client.Object{},
351+
api.BackupStorageSpec{
352+
Type: api.BackupStorageGCS,
353+
GCS: api.BackupStorageGCSSpec{
354+
Bucket: "operator-testing",
355+
Prefix: "psmdb",
356+
WorkloadIdentity: true,
357+
ChunkSize: 1024 * 1024 * 10,
358+
},
359+
},
360+
config.StorageConf{
361+
Type: storage.GCS,
362+
GCS: &gcs.Config{
363+
Bucket: "operator-testing",
364+
Prefix: "psmdb",
365+
ChunkSize: 1024 * 1024 * 10,
366+
},
367+
},
368+
},
349369
"gcs s3 compatibility": {
350370
[]client.Object{
351371
&corev1.Secret{

0 commit comments

Comments
 (0)