@@ -30,7 +30,7 @@ use stackable_operator::{
3030 apps:: v1:: { DaemonSet , DaemonSetSpec , DaemonSetUpdateStrategy , RollingUpdateDaemonSet } ,
3131 core:: v1:: {
3232 EmptyDirVolumeSource , EnvVarSource , HTTPGetAction , ObjectFieldSelector , Probe ,
33- SecretVolumeSource , ServiceAccount ,
33+ ResourceRequirements , SecretVolumeSource , ServiceAccount ,
3434 } ,
3535 } ,
3636 apimachinery:: pkg:: { apis:: meta:: v1:: LabelSelector , util:: intstr:: IntOrString } ,
@@ -48,10 +48,7 @@ use stackable_operator::{
4848 product_logging:: framework:: {
4949 STACKABLE_LOG_DIR , ValidatedContainerLogConfigChoice , vector_container,
5050 } ,
51- types:: {
52- common:: Port ,
53- kubernetes:: { ContainerName , VolumeName } ,
54- } ,
51+ types:: kubernetes:: { ContainerName , VolumeName } ,
5552 } ,
5653} ;
5754
@@ -62,12 +59,9 @@ use crate::{
6259 operations:: graceful_shutdown:: add_graceful_shutdown_config,
6360} ;
6461
65- pub const CONFIG_FILE : & str = "config.json" ;
66-
6762pub const BUNDLES_ACTIVE_DIR : & str = "/bundles/active" ;
6863pub const BUNDLES_INCOMING_DIR : & str = "/bundles/incoming" ;
6964pub const BUNDLES_TMP_DIR : & str = "/bundles/tmp" ;
70- pub const BUNDLE_BUILDER_PORT : Port = Port ( 3030 ) ;
7165
7266stackable_operator:: constant!( CONFIG_VOLUME_NAME : VolumeName = "config" ) ;
7367const CONFIG_DIR : & str = "/stackable/config" ;
@@ -181,6 +175,16 @@ fn container_name(container: &Container) -> ContainerName {
181175 . expect ( "Container enum variants are valid container names" )
182176}
183177
178+ /// The CPU and memory requests/limits shared by the bundle-builder and user-info-fetcher sidecars.
179+ fn sidecar_resource_requirements ( ) -> ResourceRequirements {
180+ ResourceRequirementsBuilder :: new ( )
181+ . with_cpu_request ( "100m" )
182+ . with_cpu_limit ( "200m" )
183+ . with_memory_request ( "128Mi" )
184+ . with_memory_limit ( "128Mi" )
185+ . build ( )
186+ }
187+
184188/// The strict-mode `bash` entrypoint shared by the prepare, bundle-builder, and OPA containers.
185189/// The actual script is passed via `.args(...)`.
186190fn bash_entrypoint_command ( ) -> Vec < String > {
@@ -281,22 +285,15 @@ pub fn build_server_rolegroup_daemonset(
281285 . context ( AddVolumeMountSnafu ) ?
282286 . add_volume_mount ( LOG_VOLUME_NAME . as_ref ( ) , STACKABLE_LOG_DIR )
283287 . context ( AddVolumeMountSnafu ) ?
284- . resources (
285- ResourceRequirementsBuilder :: new ( )
286- . with_cpu_request ( "100m" )
287- . with_cpu_limit ( "200m" )
288- . with_memory_request ( "128Mi" )
289- . with_memory_limit ( "128Mi" )
290- . build ( ) ,
291- )
288+ . resources ( sidecar_resource_requirements ( ) )
292289 . readiness_probe ( http_readiness_probe (
293290 BUNDLE_BUILDER_PROBE_PATH ,
294- IntOrString :: Int ( BUNDLE_BUILDER_PORT . into ( ) ) ,
291+ IntOrString :: Int ( build :: BUNDLE_BUILDER_PORT . into ( ) ) ,
295292 None ,
296293 ) )
297294 . liveness_probe ( http_liveness_probe (
298295 BUNDLE_BUILDER_PROBE_PATH ,
299- IntOrString :: Int ( BUNDLE_BUILDER_PORT . into ( ) ) ,
296+ IntOrString :: Int ( build :: BUNDLE_BUILDER_PORT . into ( ) ) ,
300297 None ,
301298 ) ) ;
302299 add_stackable_rust_cli_env_vars (
@@ -444,18 +441,17 @@ pub fn build_server_rolegroup_daemonset(
444441 . image_from_product_image ( resolved_product_image) // inherit the pull policy and pull secrets, and then...
445442 . image ( user_info_fetcher_image) // ...override the image
446443 . command ( vec ! [ "stackable-opa-user-info-fetcher" . to_string( ) ] )
447- . add_env_var ( "CONFIG" , format ! ( "{CONFIG_DIR}/user-info-fetcher.json" ) )
444+ . add_env_var (
445+ "CONFIG" ,
446+ format ! (
447+ "{CONFIG_DIR}/{file}" ,
448+ file = build:: properties:: ConfigFileName :: UserInfoFetcher
449+ ) ,
450+ )
448451 . add_env_var ( "CREDENTIALS_DIR" , USER_INFO_FETCHER_CREDENTIALS_DIR )
449452 . add_volume_mount ( CONFIG_VOLUME_NAME . as_ref ( ) , CONFIG_DIR )
450453 . context ( AddVolumeMountSnafu ) ?
451- . resources (
452- ResourceRequirementsBuilder :: new ( )
453- . with_cpu_request ( "100m" )
454- . with_cpu_limit ( "200m" )
455- . with_memory_request ( "128Mi" )
456- . with_memory_limit ( "128Mi" )
457- . build ( ) ,
458- ) ;
454+ . resources ( sidecar_resource_requirements ( ) ) ;
459455 add_stackable_rust_cli_env_vars (
460456 & mut cb_user_info_fetcher,
461457 cluster_info,
@@ -722,13 +718,15 @@ fn build_opa_start_command(
722718 . collect :: < Vec < _ > > ( )
723719 . join ( " " ) ;
724720
721+ let config_file = build:: properties:: ConfigFileName :: ConfigJson ;
722+
725723 // TODO: Think about adding --shutdown-wait-period, as suggested by https://github.com/open-policy-agent/opa/issues/2764
726724 formatdoc ! { "
727725 {COMMON_BASH_TRAP_FUNCTIONS}
728726 {remove_vector_shutdown_file_command}
729727 prepare_signal_handlers
730728 containerdebug --output={STACKABLE_LOG_DIR}/containerdebug-state.json --loop &
731- opa run -s -a 0.0.0.0:{bind_port} -c {CONFIG_DIR}/{CONFIG_FILE } -l {opa_log_level} --shutdown-grace-period {shutdown_grace_period_s} --disable-telemetry {tls_flags} {extra_cli_args} {logging_redirects} &
729+ opa run -s -a 0.0.0.0:{bind_port} -c {CONFIG_DIR}/{config_file } -l {opa_log_level} --shutdown-grace-period {shutdown_grace_period_s} --disable-telemetry {tls_flags} {extra_cli_args} {logging_redirects} &
732730 wait_for_termination $!
733731 {create_vector_shutdown_file_command}
734732 " ,
0 commit comments