@@ -39,14 +39,14 @@ use mz_cloud_provider::CloudProvider;
3939use mz_cloud_resources:: crd:: {
4040 ManagedResource ,
4141 balancer:: v1alpha1:: { Balancer , BalancerSpec } ,
42+ console:: v1alpha1:: { BalancerdRef , Console , ConsoleSpec } ,
4243 materialize:: v1alpha1:: { Materialize , MaterializeRolloutStrategy , MaterializeStatus } ,
4344} ;
4445use mz_license_keys:: validate;
4546use mz_orchestrator_kubernetes:: KubernetesImagePullPolicy ;
4647use mz_orchestrator_tracing:: TracingCliArgs ;
4748use mz_ore:: { cast:: CastFrom , cli:: KeyValueArg , instrument} ;
4849
49- pub mod console;
5050pub mod environmentd;
5151
5252pub struct Config {
@@ -85,10 +85,6 @@ pub struct Config {
8585 pub clusterd_node_selector : Vec < KeyValueArg < String , String > > ,
8686 pub clusterd_affinity : Option < Affinity > ,
8787 pub clusterd_tolerations : Option < Vec < Toleration > > ,
88- pub console_node_selector : Vec < KeyValueArg < String , String > > ,
89- pub console_affinity : Option < Affinity > ,
90- pub console_tolerations : Option < Vec < Toleration > > ,
91- pub console_default_resources : Option < ResourceRequirements > ,
9288 pub image_pull_policy : KubernetesImagePullPolicy ,
9389 pub network_policies_internal_enabled : bool ,
9490 pub network_policies_ingress_enabled : bool ,
@@ -117,10 +113,6 @@ pub struct Config {
117113 pub environmentd_internal_http_port : u16 ,
118114 pub environmentd_internal_persist_pubsub_port : u16 ,
119115
120- pub balancerd_http_port : u16 ,
121-
122- pub console_http_port : u16 ,
123-
124116 pub default_certificate_specs : DefaultCertificateSpecs ,
125117
126118 pub disable_license_key_checks : bool ,
@@ -281,6 +273,7 @@ impl k8s_controller::Context for Context {
281273 ) -> Result < Option < Action > , Self :: Error > {
282274 let mz_api: Api < Materialize > = Api :: namespaced ( client. clone ( ) , & mz. namespace ( ) ) ;
283275 let balancer_api: Api < Balancer > = Api :: namespaced ( client. clone ( ) , & mz. namespace ( ) ) ;
276+ let console_api: Api < Console > = Api :: namespaced ( client. clone ( ) , & mz. namespace ( ) ) ;
284277 let secret_api: Api < Secret > = Api :: namespaced ( client. clone ( ) , & mz. namespace ( ) ) ;
285278
286279 let status = mz. status ( ) ;
@@ -695,7 +688,7 @@ impl k8s_controller::Context for Context {
695688 } ,
696689 ) ,
697690 frontegg_routing : None ,
698- resource_id : Some ( status. resource_id ) ,
691+ resource_id : Some ( status. resource_id . clone ( ) ) ,
699692 } ,
700693 status : None ,
701694 } ;
@@ -712,33 +705,50 @@ impl k8s_controller::Context for Context {
712705 // and the console relies on the balancer service existing, which is
713706 // enforced by wait_for_balancer
714707
715- let Some ( ( _, environmentd_image_tag) ) = mz. spec . environmentd_image_ref . rsplit_once ( ':' )
716- else {
717- return Err ( Error :: Anyhow ( anyhow:: anyhow!(
718- "failed to parse environmentd image ref: {}" ,
719- mz. spec. environmentd_image_ref
720- ) ) ) ;
721- } ;
722- let console_image_tag = self
723- . config
724- . console_image_tag_map
725- . iter ( )
726- . find ( |kv| kv. key == environmentd_image_tag)
727- . map ( |kv| kv. value . clone ( ) )
728- . unwrap_or_else ( || self . config . console_image_tag_default . clone ( ) ) ;
729- let console = console:: Resources :: new (
730- & self . config ,
731- mz,
732- & matching_image_from_environmentd_image_ref (
733- & mz. spec . environmentd_image_ref ,
734- "console" ,
735- Some ( & console_image_tag) ,
736- ) ,
737- ) ;
738708 if self . config . create_console {
739- console. apply ( & client, & mz. namespace ( ) ) . await ?;
709+ let Some ( ( _, environmentd_image_tag) ) = mz. spec . environmentd_image_ref . rsplit_once ( ':' )
710+ else {
711+ return Err ( Error :: Anyhow ( anyhow:: anyhow!(
712+ "failed to parse environmentd image ref: {}" ,
713+ mz. spec. environmentd_image_ref
714+ ) ) ) ;
715+ } ;
716+ let console_image_tag = self
717+ . config
718+ . console_image_tag_map
719+ . iter ( )
720+ . find ( |kv| kv. key == environmentd_image_tag)
721+ . map ( |kv| kv. value . clone ( ) )
722+ . unwrap_or_else ( || self . config . console_image_tag_default . clone ( ) ) ;
723+ let console = Console {
724+ metadata : mz. managed_resource_meta ( mz. name_unchecked ( ) ) ,
725+ spec : ConsoleSpec {
726+ console_image_ref : matching_image_from_environmentd_image_ref (
727+ & mz. spec . environmentd_image_ref ,
728+ "console" ,
729+ Some ( & console_image_tag) ,
730+ ) ,
731+ resource_requirements : mz. spec . console_resource_requirements . clone ( ) ,
732+ replicas : Some ( mz. console_replicas ( ) ) ,
733+ external_certificate_spec : mz. spec . console_external_certificate_spec . clone ( ) ,
734+ pod_annotations : mz. spec . pod_annotations . clone ( ) ,
735+ pod_labels : mz. spec . pod_labels . clone ( ) ,
736+ balancerd : BalancerdRef {
737+ service_name : mz. balancerd_service_name ( ) ,
738+ namespace : mz. namespace ( ) ,
739+ external_certificate_spec : mz
740+ . spec
741+ . balancerd_external_certificate_spec
742+ . clone ( ) ,
743+ authenticator_kind : mz. spec . authenticator_kind ,
744+ } ,
745+ resource_id : Some ( status. resource_id ) ,
746+ } ,
747+ status : None ,
748+ } ;
749+ apply_resource ( & console_api, & console) . await ?;
740750 } else {
741- console . cleanup ( & client , & mz. namespace ( ) ) . await ?;
751+ delete_resource ( & console_api , & mz. name_prefixed ( "console" ) ) . await ?;
742752 }
743753
744754 Ok ( result)
0 commit comments