@@ -31,6 +31,10 @@ const SHUTDOWN_FILE: &str = "shutdown";
31
31
32
32
/// File name of the Vector config file
33
33
pub 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" ;
36
+ /// Name of the env var in the vector container that holds the vector aggregator address
37
+ const VECTOR_AGGREGATOR_ENV_NAME : & str = "VECTOR_AGGREGATOR_ADDRESS" ;
34
38
35
39
#[ derive( Debug , Snafu ) ]
36
40
pub enum LoggingError {
@@ -678,7 +682,6 @@ pub fn create_logback_config(
678
682
/// # }
679
683
/// #
680
684
/// # let logging = fragment::validate::<Logging<Container>>(default_logging()).unwrap();
681
- /// # let vector_aggregator_address = "vector-aggregator:6000";
682
685
/// # let role_group = RoleGroupRef {
683
686
/// # cluster: ObjectRef::<Pod>::new("test-cluster"),
684
687
/// # role: "role".into(),
@@ -702,7 +705,6 @@ pub fn create_logback_config(
702
705
/// product_logging::framework::VECTOR_CONFIG_FILE,
703
706
/// product_logging::framework::create_vector_config(
704
707
/// &role_group,
705
- /// vector_aggregator_address,
706
708
/// vector_log_config,
707
709
/// ),
708
710
/// );
@@ -712,7 +714,6 @@ pub fn create_logback_config(
712
714
/// ```
713
715
pub fn create_vector_config < T > (
714
716
role_group : & RoleGroupRef < T > ,
715
- vector_aggregator_address : & str ,
716
717
config : Option < & AutomaticContainerLogConfig > ,
717
718
) -> String
718
719
where
@@ -1330,7 +1331,7 @@ sinks:
1330
1331
inputs:
1331
1332
- extended_logs
1332
1333
type: vector
1333
- address: {vector_aggregator_address }
1334
+ address: ${VECTOR_AGGREGATOR_ENV_NAME }
1334
1335
"# ,
1335
1336
namespace = role_group. cluster. namespace. clone( ) . unwrap_or_default( ) ,
1336
1337
cluster_name = role_group. cluster. name,
@@ -1386,6 +1387,7 @@ sinks:
1386
1387
/// # image_pull_policy: "Always".into(),
1387
1388
/// # pull_secrets: None,
1388
1389
/// # };
1390
+ /// # let vector_aggregator_config_map_name = "vector-aggregator-discovery";
1389
1391
///
1390
1392
/// let mut pod_builder = PodBuilder::new();
1391
1393
/// pod_builder.metadata(ObjectMetaBuilder::default().build());
@@ -1425,6 +1427,7 @@ sinks:
1425
1427
/// "log",
1426
1428
/// logging.containers.get(&Container::Vector),
1427
1429
/// resources,
1430
+ /// vector_aggregator_config_map_name,
1428
1431
/// ).unwrap());
1429
1432
/// }
1430
1433
///
@@ -1436,6 +1439,7 @@ pub fn vector_container(
1436
1439
log_volume_name : & str ,
1437
1440
log_config : Option < & ContainerLogConfig > ,
1438
1441
resources : ResourceRequirements ,
1442
+ vector_aggregator_config_map_name : & str ,
1439
1443
) -> Result < Container , LoggingError > {
1440
1444
let log_level = if let Some ( ContainerLogConfig {
1441
1445
choice : Some ( ContainerLogConfigChoice :: Automatic ( automatic_log_config) ) ,
@@ -1473,6 +1477,11 @@ kill $vector_pid
1473
1477
"
1474
1478
) ] )
1475
1479
. add_env_var ( "VECTOR_LOG" , log_level. to_vector_literal ( ) )
1480
+ . add_env_var_from_config_map (
1481
+ VECTOR_AGGREGATOR_ENV_NAME ,
1482
+ vector_aggregator_config_map_name,
1483
+ VECTOR_AGGREGATOR_CM_KEY ,
1484
+ )
1476
1485
. add_volume_mount ( config_volume_name, STACKABLE_CONFIG_DIR )
1477
1486
. context ( AddVolumeMountsSnafu ) ?
1478
1487
. add_volume_mount ( log_volume_name, STACKABLE_LOG_DIR )
0 commit comments