@@ -80,19 +80,29 @@ func GetDefaultOVNDBClusterSpec() ovnv1.OVNDBClusterSpec {
8080 }
8181}
8282
83- func GetTLSOVNDBClusterSpec ( ) ovnv1.OVNDBClusterSpec {
83+ func getTLSOVNDBClusterSpecWithTLSSecrets ( caBundleSecretName , certSecretName string ) ovnv1.OVNDBClusterSpec {
8484 spec := GetDefaultOVNDBClusterSpec ()
8585 spec .TLS = tls.SimpleService {
8686 Ca : tls.Ca {
87- CaBundleSecretName : CABundleSecretName ,
87+ CaBundleSecretName : caBundleSecretName ,
8888 },
8989 GenericService : tls.GenericService {
90- SecretName : ptr .To (OvnDbCertSecretName ),
90+ SecretName : ptr .To (certSecretName ),
9191 },
9292 }
9393 return spec
9494}
9595
96+ func GetTLSOVNDBClusterSpec () ovnv1.OVNDBClusterSpec {
97+ return getTLSOVNDBClusterSpecWithTLSSecrets (CABundleSecretName , OvnDbCertSecretName )
98+ }
99+
100+ // ovnDBClusterTestTLSSecrets names the K8s secrets used by OVNDBCluster TLS (nil means no TLS).
101+ type ovnDBClusterTestTLSSecrets struct {
102+ CaBundle string
103+ Cert string
104+ }
105+
96106func CreateOVNDBCluster (namespace string , spec ovnv1.OVNDBClusterSpec ) client.Object {
97107 name := ovn .CreateOVNDBCluster (nil , namespace , spec )
98108 return ovn .GetOVNDBCluster (name )
@@ -113,9 +123,32 @@ func ScaleDBCluster(name types.NamespacedName, replicas int32) {
113123
114124// CreateOVNDBClusters Creates NB and SB OVNDBClusters
115125func CreateOVNDBClusters (namespace string , nad map [string ][]string , replicas int32 ) []types.NamespacedName {
126+ return createOVNDBClusters (namespace , nad , replicas , nil )
127+ }
128+
129+ // CreateTLSOVNDBClusters Creates NB and SB OVNDBClusters with TLS
130+ func CreateTLSOVNDBClusters (namespace string , nad map [string ][]string , replicas int32 ) []types.NamespacedName {
131+ return createOVNDBClusters (namespace , nad , replicas , & ovnDBClusterTestTLSSecrets {
132+ CaBundle : CABundleSecretName ,
133+ Cert : OvnDbCertSecretName ,
134+ })
135+ }
136+
137+ // CreateTLSOVNDBClustersUsingSecrets Creates NB and SB OVNDBClusters with TLS using the given secret names.
138+ func CreateTLSOVNDBClustersUsingSecrets (namespace string , nad map [string ][]string , replicas int32 , caBundleSecret , certSecret string ) []types.NamespacedName {
139+ return createOVNDBClusters (namespace , nad , replicas , & ovnDBClusterTestTLSSecrets {
140+ CaBundle : caBundleSecret ,
141+ Cert : certSecret ,
142+ })
143+ }
144+
145+ func createOVNDBClusters (namespace string , nad map [string ][]string , replicas int32 , tlsSecrets * ovnDBClusterTestTLSSecrets ) []types.NamespacedName {
116146 dbs := []types.NamespacedName {}
117147 for _ , db := range []string {ovnv1 .NBDBType , ovnv1 .SBDBType } {
118148 spec := GetDefaultOVNDBClusterSpec ()
149+ if tlsSecrets != nil {
150+ spec = getTLSOVNDBClusterSpecWithTLSSecrets (tlsSecrets .CaBundle , tlsSecrets .Cert )
151+ }
119152 stringNad := ""
120153 // OVNDBCluster doesn't allow multiple NADs, hence map len
121154 // must be <= 1
@@ -157,7 +190,11 @@ func CreateOVNDBClusters(namespace string, nad map[string][]string, replicas int
157190 endpoint := ""
158191 // Check External endpoint when NAD is set
159192 if len (nad ) == 0 {
160- endpoint , _ = ovndbcluster .GetInternalEndpoint ()
193+ if tlsSecrets != nil && db == ovnv1 .SBDBType {
194+ endpoint , _ = ovndbcluster .GetInternalEndpointRbacFullAccess ()
195+ } else {
196+ endpoint , _ = ovndbcluster .GetInternalEndpoint ()
197+ }
161198 } else {
162199 endpoint , _ = ovndbcluster .GetExternalEndpoint ()
163200 }
0 commit comments