|
1 | 1 | //! Ensures that `Pod`s are configured and running for each [`NifiCluster`] |
2 | | -use crate::config::{ |
3 | | - build_bootstrap_conf, build_nifi_properties, build_state_management_xml, |
4 | | - validated_product_config, NifiRepository, NIFI_BOOTSTRAP_CONF, NIFI_PROPERTIES, |
5 | | - NIFI_STATE_MANAGEMENT_XML, |
| 2 | +use std::{ |
| 3 | + borrow::Cow, |
| 4 | + collections::{BTreeMap, HashMap}, |
| 5 | + ops::Deref, |
| 6 | + sync::Arc, |
| 7 | + time::Duration, |
6 | 8 | }; |
7 | | -use crate::product_logging::{extend_role_group_config_map, resolve_vector_aggregator_address}; |
8 | | -use crate::{config, OPERATOR_NAME}; |
9 | 9 |
|
10 | 10 | use rand::{distributions::Alphanumeric, Rng}; |
11 | 11 | use snafu::{OptionExt, ResultExt, Snafu}; |
12 | | -use stackable_nifi_crd::{ |
13 | | - authentication::ResolvedAuthenticationMethod, Container, NifiCluster, NifiConfig, |
14 | | - NifiConfigFragment, NifiRole, NifiStatus, APP_NAME, BALANCE_PORT, BALANCE_PORT_NAME, |
15 | | - HTTPS_PORT, HTTPS_PORT_NAME, LOG_VOLUME_SIZE_IN_MIB, METRICS_PORT, METRICS_PORT_NAME, |
16 | | - PROTOCOL_PORT, PROTOCOL_PORT_NAME, STACKABLE_LOG_CONFIG_DIR, STACKABLE_LOG_DIR, |
17 | | -}; |
18 | 12 | use stackable_operator::{ |
19 | 13 | builder::{ |
20 | 14 | ConfigMapBuilder, ContainerBuilder, ObjectMetaBuilder, PodBuilder, |
@@ -52,16 +46,24 @@ use stackable_operator::{ |
52 | 46 | }, |
53 | 47 | role_utils::{Role, RoleGroupRef}, |
54 | 48 | }; |
55 | | -use std::{ |
56 | | - borrow::Cow, |
57 | | - collections::{BTreeMap, HashMap}, |
58 | | - ops::Deref, |
59 | | - sync::Arc, |
60 | | - time::Duration, |
61 | | -}; |
62 | 49 | use strum::{EnumDiscriminants, IntoStaticStr}; |
63 | 50 | use tracing::Instrument; |
64 | 51 |
|
| 52 | +use stackable_nifi_crd::{ |
| 53 | + authentication::ResolvedAuthenticationMethod, Container, NifiCluster, NifiConfig, |
| 54 | + NifiConfigFragment, NifiRole, NifiStatus, APP_NAME, BALANCE_PORT, BALANCE_PORT_NAME, |
| 55 | + HTTPS_PORT, HTTPS_PORT_NAME, LOG_VOLUME_SIZE_IN_MIB, METRICS_PORT, METRICS_PORT_NAME, |
| 56 | + PROTOCOL_PORT, PROTOCOL_PORT_NAME, STACKABLE_LOG_CONFIG_DIR, STACKABLE_LOG_DIR, |
| 57 | +}; |
| 58 | + |
| 59 | +use crate::config::{ |
| 60 | + build_bootstrap_conf, build_nifi_properties, build_state_management_xml, |
| 61 | + validated_product_config, NifiRepository, NIFI_BOOTSTRAP_CONF, NIFI_PROPERTIES, |
| 62 | + NIFI_STATE_MANAGEMENT_XML, |
| 63 | +}; |
| 64 | +use crate::product_logging::{extend_role_group_config_map, resolve_vector_aggregator_address}; |
| 65 | +use crate::{config, OPERATOR_NAME}; |
| 66 | + |
65 | 67 | pub const CONTROLLER_NAME: &str = "nificluster"; |
66 | 68 |
|
67 | 69 | const KEYSTORE_VOLUME_NAME: &str = "keystore"; |
@@ -629,6 +631,8 @@ fn build_node_rolegroup_service( |
629 | 631 | }) |
630 | 632 | } |
631 | 633 |
|
| 634 | +const USERDATA_MOUNTPOINT: &str = "/stackable/userdata"; |
| 635 | + |
632 | 636 | /// The rolegroup [`StatefulSet`] runs the rolegroup, as configured by the administrator. |
633 | 637 | /// |
634 | 638 | /// The [`Pod`](`stackable_operator::k8s_openapi::api::core::v1::Pod`)s are accessible through the |
@@ -857,6 +861,24 @@ async fn build_node_rolegroup_statefulset( |
857 | 861 | .resources(merged_config.resources.clone().into()); |
858 | 862 |
|
859 | 863 | let mut pod_builder = PodBuilder::new(); |
| 864 | + |
| 865 | + // Add user configured extra volumes if any are specified |
| 866 | + for volume in &nifi.spec.cluster_config.extra_volumes { |
| 867 | + // Extract values into vars so we make it impossible to log something other than |
| 868 | + // what we actually use to create the mounts - maybe paranoid, but hey .. |
| 869 | + let volume_name = &volume.name; |
| 870 | + let mount_point = format!("{USERDATA_MOUNTPOINT}/{}", volume.name); |
| 871 | + |
| 872 | + tracing::info!( |
| 873 | + ?volume_name, |
| 874 | + ?mount_point, |
| 875 | + ?role, |
| 876 | + "Adding user specified extra volume", |
| 877 | + ); |
| 878 | + pod_builder.add_volume(volume.clone()); |
| 879 | + container_nifi.add_volume_mount(volume_name, mount_point); |
| 880 | + } |
| 881 | + |
860 | 882 | // We want to add nifi container first for easier defaulting into this container |
861 | 883 | pod_builder.add_container(container_nifi.build()); |
862 | 884 |
|
|
0 commit comments