@@ -198,44 +198,12 @@ impl NodeConfig {
198198 /// The file should only contain cluster-wide configuration options. Node-specific options
199199 /// should be defined as environment variables.
200200 pub fn static_opensearch_config ( & self ) -> serde_json:: Value {
201- let nodes_dn = self
202- . cluster
203- . role_group_configs
204- . keys ( )
205- . map ( |role_group_name| {
206- let resource_names = ResourceNames {
207- cluster_name : self . cluster . name . clone ( ) ,
208- role_name : ValidatedCluster :: role_name ( ) ,
209- role_group_name : role_group_name. clone ( ) ,
210- } ;
211-
212- self . cluster_domain_name
213- . split ( '.' )
214- . rev ( )
215- . chain ( [
216- "svc" ,
217- self . cluster . namespace . as_ref ( ) ,
218- resource_names. headless_service_name ( ) . as_ref ( ) ,
219- & format ! (
220- "{stateful_set_name}-*" ,
221- stateful_set_name = resource_names. stateful_set_name( )
222- ) ,
223- ] )
224- . map ( |component| format ! ( "DC={component}" ) )
225- . collect :: < Vec < _ > > ( )
226- . join ( "," )
227- } )
228- . collect :: < Vec < _ > > ( ) ;
229-
230201 let mut config = json ! ( {
231202 CONFIG_OPTION_CLUSTER_NAME : self . cluster. name,
232203 // Bind to all interfaces because the IP address is not known in advance.
233204 CONFIG_OPTION_NETWORK_HOST : "0.0.0.0" ,
234205 CONFIG_OPTION_DISCOVERY_TYPE : self . discovery_type( ) ,
235- // Accept certificates generated by the secret-operator
236- CONFIG_OPTION_PLUGINS_SECURITY_NODES_DN : [
237- json!( nodes_dn) ,
238- ] ,
206+ CONFIG_OPTION_PLUGINS_SECURITY_NODES_DN : json!( self . nodes_dn( ) ) ,
239207 CONFIG_OPTION_NODE_ATTR_ROLE_GROUP : self . role_group_name,
240208 CONFIG_OPTION_PATH_LOGS : format!(
241209 "{STACKABLE_LOG_DIR}/{container}" ,
@@ -265,6 +233,41 @@ impl NodeConfig {
265233 config
266234 }
267235
236+ /// Returns the list of distinguished names (DNs) that denote the other nodes in the cluster.
237+ ///
238+ /// The list looks similar to:
239+ /// - DC=local,DC=cluster,DC=svc,DC=my-namespace,DC=opensearch-nodes-cluster-manager-headless,DC=opensearch-nodes-cluster-manager-*
240+ /// - DC=local,DC=cluster,DC=svc,DC=my-namespace,DC=opensearch-nodes-data-headless,DC=opensearch-nodes-data-*
241+ fn nodes_dn ( & self ) -> Vec < String > {
242+ self . cluster
243+ . role_group_configs
244+ . keys ( )
245+ . map ( |role_group_name| {
246+ let resource_names = ResourceNames {
247+ cluster_name : self . cluster . name . clone ( ) ,
248+ role_name : ValidatedCluster :: role_name ( ) ,
249+ role_group_name : role_group_name. clone ( ) ,
250+ } ;
251+
252+ self . cluster_domain_name
253+ . split ( '.' )
254+ . rev ( )
255+ . chain ( [
256+ "svc" ,
257+ self . cluster . namespace . as_ref ( ) ,
258+ resource_names. headless_service_name ( ) . as_ref ( ) ,
259+ & format ! (
260+ "{stateful_set_name}-*" ,
261+ stateful_set_name = resource_names. stateful_set_name( )
262+ ) ,
263+ ] )
264+ . map ( |component| format ! ( "DC={component}" ) )
265+ . collect :: < Vec < _ > > ( )
266+ . join ( "," )
267+ } )
268+ . collect ( )
269+ }
270+
268271 /// Distinguished name (DN) of the super admin certificate
269272 pub fn super_admin_dn ( & self ) -> String {
270273 // The common name field is limited to 64 characters, see RFC 5280.
@@ -687,7 +690,7 @@ mod tests {
687690 "path.logs: /stackable/log/opensearch\n " ,
688691 "plugins.security.authcz.admin_dn: CN=update-security-config.0b1e30e6-326e-4c1a-868d-ad6598b49e8b\n " ,
689692 "plugins.security.nodes_dn:\n " ,
690- "- CN=generated certificate for pod \n " ,
693+ "- DC=local,DC=cluster,DC=svc,DC=default,DC=my-opensearch-cluster-nodes-default-headless,DC=my-opensearch-cluster-nodes-default-* \n " ,
691694 "plugins.security.ssl.http.enabled: true\n " ,
692695 "plugins.security.ssl.http.pemcert_filepath: /stackable/opensearch/config/tls/server/tls.crt\n " ,
693696 "plugins.security.ssl.http.pemkey_filepath: /stackable/opensearch/config/tls/server/tls.key\n " ,
0 commit comments