@@ -10,7 +10,7 @@ use crate::{
1010 controller:: OpenSearchRoleGroupConfig ,
1111 crd:: v1alpha1,
1212 framework:: {
13- ServiceName ,
13+ RoleGroupName , ServiceName ,
1414 builder:: pod:: container:: { EnvVarName , EnvVarSet } ,
1515 role_group_utils,
1616 } ,
@@ -41,6 +41,10 @@ pub const CONFIG_OPTION_INITIAL_CLUSTER_MANAGER_NODES: &str =
4141/// Type: string
4242pub const CONFIG_OPTION_NETWORK_HOST : & str = "network.host" ;
4343
44+ /// The custom node attribute "role-group"
45+ /// Type: string
46+ pub const CONFIG_OPTION_NODE_ATTR_ROLE_GROUP : & str = "node.attr.role-group" ;
47+
4448/// A descriptive name for the node.
4549/// Type: string
4650pub const CONFIG_OPTION_NODE_NAME : & str = "node.name" ;
@@ -61,6 +65,7 @@ pub const CONFIG_OPTION_PLUGINS_SECURITY_SSL_HTTP_ENABLED: &str =
6165/// Configuration of an OpenSearch node based on the cluster and role-group configuration
6266pub struct NodeConfig {
6367 cluster : ValidatedCluster ,
68+ role_group_name : RoleGroupName ,
6469 role_group_config : OpenSearchRoleGroupConfig ,
6570 discovery_service_name : ServiceName ,
6671}
@@ -70,11 +75,13 @@ pub struct NodeConfig {
7075impl NodeConfig {
7176 pub fn new (
7277 cluster : ValidatedCluster ,
78+ role_group_name : RoleGroupName ,
7379 role_group_config : OpenSearchRoleGroupConfig ,
7480 discovery_service_name : ServiceName ,
7581 ) -> Self {
7682 Self {
7783 cluster,
84+ role_group_name,
7885 role_group_config,
7986 discovery_service_name,
8087 }
@@ -111,6 +118,10 @@ impl NodeConfig {
111118 CONFIG_OPTION_PLUGINS_SECURITY_NODES_DN . to_owned ( ) ,
112119 json ! ( [ "CN=generated certificate for pod" . to_owned( ) ] ) ,
113120 ) ;
121+ config. insert (
122+ CONFIG_OPTION_NODE_ATTR_ROLE_GROUP . to_owned ( ) ,
123+ json ! ( self . role_group_name) ,
124+ ) ;
114125
115126 for ( setting, value) in self
116127 . role_group_config
@@ -311,6 +322,8 @@ mod tests {
311322 let image: ProductImage = serde_json:: from_str ( r#"{"productVersion": "3.1.0"}"# )
312323 . expect ( "should be a valid ProductImage" ) ;
313324
325+ let role_group_name = RoleGroupName :: from_str_unsafe ( "data" ) ;
326+
314327 let role_group_config = OpenSearchRoleGroupConfig {
315328 replicas : test_config. replicas ,
316329 config : ValidatedOpenSearchConfig {
@@ -374,6 +387,7 @@ mod tests {
374387
375388 NodeConfig :: new (
376389 cluster,
390+ role_group_name,
377391 role_group_config,
378392 ServiceName :: from_str_unsafe ( "my-opensearch-cluster-manager" ) ,
379393 )
@@ -391,6 +405,7 @@ mod tests {
391405 "cluster.name: \" my-opensearch-cluster\" \n " ,
392406 "discovery.type: \" zen\" \n " ,
393407 "network.host: \" 0.0.0.0\" \n " ,
408+ "node.attr.role-group: \" data\" \n " ,
394409 "plugins.security.nodes_dn: [\" CN=generated certificate for pod\" ]\n " ,
395410 "test: \" value\" "
396411 )
0 commit comments