@@ -31,6 +31,8 @@ const SHUTDOWN_FILE: &str = "shutdown";
3131
3232/// File name of the Vector config file
3333pub const VECTOR_CONFIG_FILE : & str = "vector.yaml" ;
34+ /// Key in the discovery ConfigMap that holds the vector aggregator address
35+ const VECTOR_AGGREGATOR_CM_KEY : & str = "ADDRESS" ;
3436
3537#[ derive( Debug , Snafu ) ]
3638pub enum LoggingError {
@@ -678,7 +680,6 @@ pub fn create_logback_config(
678680/// # }
679681/// #
680682/// # let logging = fragment::validate::<Logging<Container>>(default_logging()).unwrap();
681- /// # let vector_aggregator_address = "vector-aggregator:6000";
682683/// # let role_group = RoleGroupRef {
683684/// # cluster: ObjectRef::<Pod>::new("test-cluster"),
684685/// # role: "role".into(),
@@ -702,7 +703,6 @@ pub fn create_logback_config(
702703/// product_logging::framework::VECTOR_CONFIG_FILE,
703704/// product_logging::framework::create_vector_config(
704705/// &role_group,
705- /// vector_aggregator_address,
706706/// vector_log_config,
707707/// ),
708708/// );
@@ -712,7 +712,6 @@ pub fn create_logback_config(
712712/// ```
713713pub fn create_vector_config < T > (
714714 role_group : & RoleGroupRef < T > ,
715- vector_aggregator_address : & str ,
716715 config : Option < & AutomaticContainerLogConfig > ,
717716) -> String
718717where
@@ -1330,7 +1329,7 @@ sinks:
13301329 inputs:
13311330 - extended_logs
13321331 type: vector
1333- address: {vector_aggregator_address}
1332+ address: $VECTOR_AGGREGATOR_ADDRESS
13341333"# ,
13351334 namespace = role_group. cluster. namespace. clone( ) . unwrap_or_default( ) ,
13361335 cluster_name = role_group. cluster. name,
@@ -1419,14 +1418,20 @@ sinks:
14191418/// );
14201419///
14211420/// if logging.enable_vector_agent {
1422- /// pod_builder.add_container(product_logging::framework::vector_container(
1423- /// &resolved_product_image,
1424- /// "config",
1425- /// "log",
1426- /// logging.containers.get(&Container::Vector),
1427- /// resources,
1428- /// ).unwrap());
1429- /// }
1421+ /// if let Some(vector_aggregator_config_map_name) = spec
1422+ /// .cluster_config
1423+ /// .vector_aggregator_config_map_name
1424+ /// .to_owned()
1425+ /// {
1426+ /// pod_builder.add_container(product_logging::framework::vector_container(
1427+ /// &resolved_product_image,
1428+ /// "config",
1429+ /// "log",
1430+ /// logging.containers.get(&Container::Vector),
1431+ /// resources,
1432+ /// vector_aggregator_config_map_name,
1433+ /// ).unwrap());
1434+ /// }
14301435///
14311436/// pod_builder.build().unwrap();
14321437/// ```
@@ -1436,6 +1441,7 @@ pub fn vector_container(
14361441 log_volume_name : & str ,
14371442 log_config : Option < & ContainerLogConfig > ,
14381443 resources : ResourceRequirements ,
1444+ vector_aggregator_config_map_name : & str ,
14391445) -> Result < Container , LoggingError > {
14401446 let log_level = if let Some ( ContainerLogConfig {
14411447 choice : Some ( ContainerLogConfigChoice :: Automatic ( automatic_log_config) ) ,
@@ -1473,6 +1479,11 @@ kill $vector_pid
14731479"
14741480 ) ] )
14751481 . add_env_var ( "VECTOR_LOG" , log_level. to_vector_literal ( ) )
1482+ . add_env_var_from_config_map (
1483+ "VECTOR_AGGREGATOR_ADDRESS" ,
1484+ vector_aggregator_config_map_name,
1485+ VECTOR_AGGREGATOR_CM_KEY ,
1486+ )
14761487 . add_volume_mount ( config_volume_name, STACKABLE_CONFIG_DIR )
14771488 . context ( AddVolumeMountsSnafu ) ?
14781489 . add_volume_mount ( log_volume_name, STACKABLE_LOG_DIR )
0 commit comments