@@ -398,12 +398,16 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
398
398
secretKey = tenantReq .SecretKey
399
399
}
400
400
401
- secretName := fmt .Sprintf ("%s-secret" , * tenantReq .Name )
401
+ tenantName := * tenantReq .Name
402
+ secretName := fmt .Sprintf ("%s-secret" , tenantName )
402
403
imm := true
403
404
404
405
instanceSecret := corev1.Secret {
405
406
ObjectMeta : metav1.ObjectMeta {
406
407
Name : secretName ,
408
+ Labels : map [string ]string {
409
+ operator .TenantLabel : tenantName ,
410
+ },
407
411
},
408
412
Immutable : & imm ,
409
413
Data : map [string ][]byte {
@@ -432,7 +436,7 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
432
436
//Construct a MinIO Instance with everything we are getting from parameters
433
437
minInst := operator.Tenant {
434
438
ObjectMeta : metav1.ObjectMeta {
435
- Name : * tenantReq . Name ,
439
+ Name : tenantName ,
436
440
},
437
441
Spec : operator.TenantSpec {
438
442
Image : minioImage ,
@@ -522,6 +526,9 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
522
526
externalTLSCertificateSecret := corev1.Secret {
523
527
ObjectMeta : metav1.ObjectMeta {
524
528
Name : externalTLSCertificateSecretName ,
529
+ Labels : map [string ]string {
530
+ operator .TenantLabel : tenantName ,
531
+ },
525
532
},
526
533
Type : corev1 .SecretTypeTLS ,
527
534
Immutable : & imm ,
@@ -549,13 +556,13 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
549
556
})
550
557
// KES client mTLSCertificates used by MinIO instance, only if autoCert is not enabled
551
558
if ! minInst .Spec .RequestAutoCert {
552
- minInst .Spec .ExternalClientCertSecret , err = getTenantExternalClientCertificates (ctx , clientset , ns , tenantReq .Encryption , secretName )
559
+ minInst .Spec .ExternalClientCertSecret , err = getTenantExternalClientCertificates (ctx , clientset , ns , tenantReq .Encryption , secretName , tenantName )
553
560
if err != nil {
554
561
return nil , err
555
562
}
556
563
}
557
564
// KES configuration for Tenant instance
558
- minInst .Spec .KES , err = getKESConfiguration (ctx , clientset , ns , tenantReq .Encryption , secretName , minInst .Spec .RequestAutoCert )
565
+ minInst .Spec .KES , err = getKESConfiguration (ctx , clientset , ns , tenantReq .Encryption , secretName , tenantName , minInst .Spec .RequestAutoCert )
559
566
if err != nil {
560
567
return nil , err
561
568
}
@@ -571,14 +578,17 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
571
578
}
572
579
573
580
if enableConsole {
574
- consoleSelector := fmt .Sprintf ("%s-console" , * tenantReq . Name )
581
+ consoleSelector := fmt .Sprintf ("%s-console" , tenantName )
575
582
consoleSecretName := fmt .Sprintf ("%s-secret" , consoleSelector )
576
583
consoleAccess = RandomCharString (16 )
577
584
consoleSecret = RandomCharString (32 )
578
585
imm := true
579
586
instanceSecret := corev1.Secret {
580
587
ObjectMeta : metav1.ObjectMeta {
581
588
Name : consoleSecretName ,
589
+ Labels : map [string ]string {
590
+ operator .TenantLabel : tenantName ,
591
+ },
582
592
},
583
593
Immutable : & imm ,
584
594
Data : map [string ][]byte {
@@ -641,6 +651,9 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
641
651
consoleExternalTLSCertificateSecret := corev1.Secret {
642
652
ObjectMeta : metav1.ObjectMeta {
643
653
Name : consoleExternalTLSCertificateSecretName ,
654
+ Labels : map [string ]string {
655
+ operator .TenantLabel : tenantName ,
656
+ },
644
657
},
645
658
Type : corev1 .SecretTypeTLS ,
646
659
Immutable : & imm ,
@@ -694,7 +707,7 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
694
707
695
708
if tenantReq .ImagePullSecret != "" {
696
709
imagePullSecret = tenantReq .ImagePullSecret
697
- } else if imagePullSecret , err = setImageRegistry (ctx , * tenantReq . Name , tenantReq .ImageRegistry , clientset .CoreV1 (), ns ); err != nil {
710
+ } else if imagePullSecret , err = setImageRegistry (ctx , tenantName , tenantReq .ImageRegistry , clientset .CoreV1 (), ns ); err != nil {
698
711
log .Println ("error setting image registry secret:" , err )
699
712
return nil , err
700
713
}
@@ -722,7 +735,7 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
722
735
723
736
// Integratrions
724
737
if os .Getenv ("GKE_INTEGRATION" ) != "" {
725
- err := gkeIntegration (clientset , * tenantReq . Name , ns , session .SessionToken )
738
+ err := gkeIntegration (clientset , tenantName , ns , session .SessionToken )
726
739
if err != nil {
727
740
return nil , err
728
741
}
@@ -771,6 +784,9 @@ func setImageRegistry(ctx context.Context, tenantName string, req *models.ImageR
771
784
instanceSecret := corev1.Secret {
772
785
ObjectMeta : metav1.ObjectMeta {
773
786
Name : pullSecretName ,
787
+ Labels : map [string ]string {
788
+ operator .TenantLabel : tenantName ,
789
+ },
774
790
},
775
791
Data : map [string ][]byte {
776
792
corev1 .DockerConfigJsonKey : []byte (string (imRegistryJSON )),
@@ -1388,7 +1404,7 @@ func parseNodeSelectorTerm(term *corev1.NodeSelectorTerm) *models.NodeSelectorTe
1388
1404
return & t
1389
1405
}
1390
1406
1391
- func getTenantExternalClientCertificates (ctx context.Context , clientSet * kubernetes.Clientset , ns string , encryptionCfg * models.EncryptionConfiguration , secretName string ) (clientCertificates * operator.LocalCertificateReference , err error ) {
1407
+ func getTenantExternalClientCertificates (ctx context.Context , clientSet * kubernetes.Clientset , ns string , encryptionCfg * models.EncryptionConfiguration , secretName , tenantName string ) (clientCertificates * operator.LocalCertificateReference , err error ) {
1392
1408
instanceExternalClientCertificateSecretName := fmt .Sprintf ("%s-instance-external-client-mtls-certificates" , secretName )
1393
1409
// If there's an error during this process we delete all KES configuration secrets
1394
1410
defer func () {
@@ -1413,6 +1429,9 @@ func getTenantExternalClientCertificates(ctx context.Context, clientSet *kuberne
1413
1429
instanceExternalClientCertificateSecret := corev1.Secret {
1414
1430
ObjectMeta : metav1.ObjectMeta {
1415
1431
Name : instanceExternalClientCertificateSecretName ,
1432
+ Labels : map [string ]string {
1433
+ operator .TenantLabel : tenantName ,
1434
+ },
1416
1435
},
1417
1436
Type : corev1 .SecretTypeTLS ,
1418
1437
Immutable : & imm ,
@@ -1433,7 +1452,7 @@ func getTenantExternalClientCertificates(ctx context.Context, clientSet *kuberne
1433
1452
return clientCertificates , nil
1434
1453
}
1435
1454
1436
- func getKESConfiguration (ctx context.Context , clientSet * kubernetes.Clientset , ns string , encryptionCfg * models.EncryptionConfiguration , secretName string , autoCert bool ) (kesConfiguration * operator.KESConfig , err error ) {
1455
+ func getKESConfiguration (ctx context.Context , clientSet * kubernetes.Clientset , ns string , encryptionCfg * models.EncryptionConfiguration , secretName , tenantName string , autoCert bool ) (kesConfiguration * operator.KESConfig , err error ) {
1437
1456
// secrets used by the KES configuration
1438
1457
instanceExternalClientCertificateSecretName := fmt .Sprintf ("%s-instance-external-client-mtls-certificates" , secretName )
1439
1458
kesExternalCertificateSecretName := fmt .Sprintf ("%s-kes-external-mtls-certificates" , secretName )
@@ -1489,6 +1508,9 @@ func getKESConfiguration(ctx context.Context, clientSet *kubernetes.Clientset, n
1489
1508
kesExternalCertificateSecret := corev1.Secret {
1490
1509
ObjectMeta : metav1.ObjectMeta {
1491
1510
Name : kesExternalCertificateSecretName ,
1511
+ Labels : map [string ]string {
1512
+ operator .TenantLabel : tenantName ,
1513
+ },
1492
1514
},
1493
1515
Type : corev1 .SecretTypeTLS ,
1494
1516
Immutable : & imm ,
@@ -1674,6 +1696,9 @@ func getKESConfiguration(ctx context.Context, clientSet *kubernetes.Clientset, n
1674
1696
kesClientCertSecret := corev1.Secret {
1675
1697
ObjectMeta : metav1.ObjectMeta {
1676
1698
Name : kesClientCertSecretName ,
1699
+ Labels : map [string ]string {
1700
+ operator .TenantLabel : tenantName ,
1701
+ },
1677
1702
},
1678
1703
Immutable : & imm ,
1679
1704
Data : mTLSCertificates ,
@@ -1697,6 +1722,9 @@ func getKESConfiguration(ctx context.Context, clientSet *kubernetes.Clientset, n
1697
1722
kesConfigurationSecret := corev1.Secret {
1698
1723
ObjectMeta : metav1.ObjectMeta {
1699
1724
Name : kesConfigurationSecretName ,
1725
+ Labels : map [string ]string {
1726
+ operator .TenantLabel : tenantName ,
1727
+ },
1700
1728
},
1701
1729
Immutable : & imm ,
1702
1730
Data : map [string ][]byte {
0 commit comments