@@ -433,6 +433,7 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
433433 tenantReq := params .Body
434434 minioImage := tenantReq .Image
435435 ctx := context .Background ()
436+ consoleHasTLS := false
436437
437438 if minioImage == "" {
438439 minImg , err := cluster .GetMinioImage ()
@@ -579,19 +580,20 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
579580 }
580581
581582 isEncryptionEnabled := false
582- if tenantReq .EnableTLS != nil && * tenantReq .EnableTLS {
583- // If user request autoCert, Operator will generate certificate keypair for MinIO (server), Console (server) and KES (server and app mTLS)
584- isEncryptionEnabled = true
583+
584+ if tenantReq .EnableTLS != nil {
585+ // if enableTLS is defined in the create tenant request we assign the value
586+ // to the RequestAutoCert attribute in the tenant spec
585587 minInst .Spec .RequestAutoCert = tenantReq .EnableTLS
588+ if * tenantReq .EnableTLS {
589+ // requestAutoCert is enabled, MinIO will be deployed with TLS enabled and encryption can be enabled
590+ isEncryptionEnabled = true
591+ consoleHasTLS = true
592+ }
586593 }
587-
588- if (minInst .Spec .RequestAutoCert == nil || (minInst .Spec .RequestAutoCert != nil && ! * minInst .Spec .RequestAutoCert )) &&
589- tenantReq .TLS != nil &&
590- len (tenantReq .TLS .Minio ) > 0 {
591- // User provided TLS certificates for MinIO
594+ // External TLS certificates for MinIO
595+ if tenantReq .TLS != nil && len (tenantReq .TLS .Minio ) > 0 {
592596 isEncryptionEnabled = true
593- // disable autoCert
594- minInst .Spec .RequestAutoCert = swag .Bool (false )
595597 // Certificates used by the MinIO instance
596598 externalCertSecretName := fmt .Sprintf ("%s-instance-external-certificates" , secretName )
597599 externalCertSecret , err := createOrReplaceExternalCertSecrets (ctx , & k8sClient , ns , tenantReq .TLS .Minio , externalCertSecretName , tenantName )
@@ -600,15 +602,10 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
600602 }
601603 minInst .Spec .ExternalCertSecret = externalCertSecret
602604 }
603-
605+ // If encryption configuration is present and TLS will be enabled (using AutoCert or External certificates)
604606 if tenantReq .Encryption != nil && isEncryptionEnabled {
605- // Enable auto encryption
606- minInst .Spec .Env = append (minInst .Spec .Env , corev1.EnvVar {
607- Name : "MINIO_KMS_AUTO_ENCRYPTION" ,
608- Value : "on" ,
609- })
610- // KES client mTLSCertificates used by MinIO instance, only if autoCert is not enabled
611- if minInst .Spec .RequestAutoCert == nil || (minInst .Spec .RequestAutoCert != nil && ! * minInst .Spec .RequestAutoCert ) {
607+ // KES client mTLSCertificates used by MinIO instance
608+ if tenantReq .Encryption .Client != nil {
612609 tenantExternalClientCertSecretName := fmt .Sprintf ("%s-tenant-external-client-cert" , secretName )
613610 certificates := []* models.KeyPairConfiguration {tenantReq .Encryption .Client }
614611 certificateSecrets , err := createOrReplaceExternalCertSecrets (ctx , & k8sClient , ns , certificates , tenantExternalClientCertSecretName , tenantName )
@@ -619,8 +616,9 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
619616 minInst .Spec .ExternalClientCertSecret = certificateSecrets [0 ]
620617 }
621618 }
619+
622620 // KES configuration for Tenant instance
623- minInst .Spec .KES , err = getKESConfiguration (ctx , & k8sClient , ns , tenantReq .Encryption , secretName , tenantName , minInst . Spec . RequestAutoCert )
621+ minInst .Spec .KES , err = getKESConfiguration (ctx , & k8sClient , ns , tenantReq .Encryption , secretName , tenantName )
624622 if err != nil {
625623 return nil , prepareError (errorGeneric )
626624 }
@@ -661,7 +659,32 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
661659 },
662660 }
663661
664- // Enable IDP (Open ID Connect) for console
662+ minInst .Spec .Console = & operator.ConsoleConfiguration {
663+ Replicas : 1 ,
664+ Image : ConsoleImageVersion ,
665+ ConsoleSecret : & corev1.LocalObjectReference {Name : consoleSecretName },
666+ Resources : corev1.ResourceRequirements {
667+ Requests : map [corev1.ResourceName ]resource.Quantity {
668+ "memory" : resource .MustParse ("64Mi" ),
669+ },
670+ },
671+ }
672+ if tenantReq .TLS != nil && tenantReq .TLS .Console != nil {
673+ consoleHasTLS = true
674+ // Certificates used by the console instance
675+ externalCertSecretName := fmt .Sprintf ("%s-console-external-certificates" , secretName )
676+ certificates := []* models.KeyPairConfiguration {tenantReq .TLS .Console }
677+ externalCertSecret , err := createOrReplaceExternalCertSecrets (ctx , & k8sClient , ns , certificates , externalCertSecretName , tenantName )
678+ if err != nil {
679+ return nil , prepareError (errorGeneric )
680+ }
681+ if len (externalCertSecret ) > 0 {
682+ minInst .Spec .Console .ExternalCertSecret = externalCertSecret [0 ]
683+ }
684+ }
685+
686+ // If IDP is not already enabled via LDAP (Active Directory) and OIDC configuration is present then
687+ // enable oidc for console
665688 if ! idpEnabled && tenantReq .Idp != nil && tenantReq .Idp .Oidc != nil {
666689 url := * tenantReq .Idp .Oidc .URL
667690 clientID := * tenantReq .Idp .Oidc .ClientID
@@ -672,7 +695,8 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
672695 instanceSecret .Data ["CONSOLE_IDP_SECRET" ] = []byte (secretID )
673696 consoleScheme := "http"
674697 consolePort := 9090
675- if minInst .Spec .RequestAutoCert != nil && * minInst .Spec .RequestAutoCert {
698+ // If Console will be deployed with TLS enabled (using AutoCert or External certificates)
699+ if consoleHasTLS {
676700 consoleScheme = "https"
677701 consolePort = 9443
678702 }
@@ -687,30 +711,6 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
687711 return nil , prepareError (errorGeneric )
688712 }
689713
690- const consoleVersion = "minio/console:v0.4.6"
691- minInst .Spec .Console = & operator.ConsoleConfiguration {
692- Replicas : 1 ,
693- Image : consoleVersion ,
694- ConsoleSecret : & corev1.LocalObjectReference {Name : consoleSecretName },
695- Resources : corev1.ResourceRequirements {
696- Requests : map [corev1.ResourceName ]resource.Quantity {
697- "memory" : resource .MustParse ("64Mi" ),
698- },
699- },
700- }
701- if (minInst .Spec .RequestAutoCert == nil || (minInst .Spec .RequestAutoCert != nil && ! * minInst .Spec .RequestAutoCert )) && tenantReq .TLS != nil && tenantReq .TLS .Console != nil {
702- // Certificates used by the console instance
703- externalCertSecretName := fmt .Sprintf ("%s-console-external-certificates" , secretName )
704- certificates := []* models.KeyPairConfiguration {tenantReq .TLS .Console }
705- externalCertSecret , err := createOrReplaceExternalCertSecrets (ctx , & k8sClient , ns , certificates , externalCertSecretName , tenantName )
706- if err != nil {
707- return nil , prepareError (errorGeneric )
708- }
709- if len (externalCertSecret ) > 0 {
710- minInst .Spec .Console .ExternalCertSecret = externalCertSecret [0 ]
711- }
712- }
713-
714714 // Set Labels, Annotations and Node Selector for Console
715715 if tenantReq .Console != nil {
716716 minInst .Spec .Console .Annotations = tenantReq .Console .Annotations
0 commit comments