@@ -38,14 +38,14 @@ use mz_cloud_provider::CloudProvider;
3838use mz_cloud_resources:: crd:: {
3939 ManagedResource ,
4040 balancer:: v1alpha1:: { Balancer , BalancerSpec } ,
41+ console:: v1alpha1:: { BalancerdRef , Console , ConsoleSpec } ,
4142 materialize:: v1alpha1:: { Materialize , MaterializeRolloutStrategy , MaterializeStatus } ,
4243} ;
4344use mz_license_keys:: validate;
4445use mz_orchestrator_kubernetes:: KubernetesImagePullPolicy ;
4546use mz_orchestrator_tracing:: TracingCliArgs ;
4647use mz_ore:: { cast:: CastFrom , cli:: KeyValueArg , instrument} ;
4748
48- pub mod console;
4949pub mod environmentd;
5050
5151pub struct Config {
@@ -84,10 +84,6 @@ pub struct Config {
8484 pub clusterd_node_selector : Vec < KeyValueArg < String , String > > ,
8585 pub clusterd_affinity : Option < Affinity > ,
8686 pub clusterd_tolerations : Option < Vec < Toleration > > ,
87- pub console_node_selector : Vec < KeyValueArg < String , String > > ,
88- pub console_affinity : Option < Affinity > ,
89- pub console_tolerations : Option < Vec < Toleration > > ,
90- pub console_default_resources : Option < ResourceRequirements > ,
9187 pub image_pull_policy : KubernetesImagePullPolicy ,
9288 pub network_policies_internal_enabled : bool ,
9389 pub network_policies_ingress_enabled : bool ,
@@ -116,10 +112,6 @@ pub struct Config {
116112 pub environmentd_internal_http_port : u16 ,
117113 pub environmentd_internal_persist_pubsub_port : u16 ,
118114
119- pub balancerd_http_port : u16 ,
120-
121- pub console_http_port : u16 ,
122-
123115 pub default_certificate_specs : DefaultCertificateSpecs ,
124116
125117 pub disable_license_key_checks : bool ,
@@ -277,6 +269,7 @@ impl k8s_controller::Context for Context {
277269 ) -> Result < Option < Action > , Self :: Error > {
278270 let mz_api: Api < Materialize > = Api :: namespaced ( client. clone ( ) , & mz. namespace ( ) ) ;
279271 let balancer_api: Api < Balancer > = Api :: namespaced ( client. clone ( ) , & mz. namespace ( ) ) ;
272+ let console_api: Api < Console > = Api :: namespaced ( client. clone ( ) , & mz. namespace ( ) ) ;
280273 let secret_api: Api < Secret > = Api :: namespaced ( client. clone ( ) , & mz. namespace ( ) ) ;
281274
282275 let status = mz. status ( ) ;
@@ -649,7 +642,7 @@ impl k8s_controller::Context for Context {
649642 } ,
650643 ) ,
651644 frontegg_routing : None ,
652- resource_id : Some ( status. resource_id ) ,
645+ resource_id : Some ( status. resource_id . clone ( ) ) ,
653646 } ,
654647 status : None ,
655648 } ;
@@ -666,33 +659,50 @@ impl k8s_controller::Context for Context {
666659 // and the console relies on the balancer service existing, which is
667660 // enforced by wait_for_balancer
668661
669- let Some ( ( _, environmentd_image_tag) ) = mz. spec . environmentd_image_ref . rsplit_once ( ':' )
670- else {
671- return Err ( Error :: Anyhow ( anyhow:: anyhow!(
672- "failed to parse environmentd image ref: {}" ,
673- mz. spec. environmentd_image_ref
674- ) ) ) ;
675- } ;
676- let console_image_tag = self
677- . config
678- . console_image_tag_map
679- . iter ( )
680- . find ( |kv| kv. key == environmentd_image_tag)
681- . map ( |kv| kv. value . clone ( ) )
682- . unwrap_or_else ( || self . config . console_image_tag_default . clone ( ) ) ;
683- let console = console:: Resources :: new (
684- & self . config ,
685- mz,
686- & matching_image_from_environmentd_image_ref (
687- & mz. spec . environmentd_image_ref ,
688- "console" ,
689- Some ( & console_image_tag) ,
690- ) ,
691- ) ;
692662 if self . config . create_console {
693- console. apply ( & client, & mz. namespace ( ) ) . await ?;
663+ let Some ( ( _, environmentd_image_tag) ) = mz. spec . environmentd_image_ref . rsplit_once ( ':' )
664+ else {
665+ return Err ( Error :: Anyhow ( anyhow:: anyhow!(
666+ "failed to parse environmentd image ref: {}" ,
667+ mz. spec. environmentd_image_ref
668+ ) ) ) ;
669+ } ;
670+ let console_image_tag = self
671+ . config
672+ . console_image_tag_map
673+ . iter ( )
674+ . find ( |kv| kv. key == environmentd_image_tag)
675+ . map ( |kv| kv. value . clone ( ) )
676+ . unwrap_or_else ( || self . config . console_image_tag_default . clone ( ) ) ;
677+ let console = Console {
678+ metadata : mz. managed_resource_meta ( mz. name_unchecked ( ) ) ,
679+ spec : ConsoleSpec {
680+ console_image_ref : matching_image_from_environmentd_image_ref (
681+ & mz. spec . environmentd_image_ref ,
682+ "console" ,
683+ Some ( & console_image_tag) ,
684+ ) ,
685+ resource_requirements : mz. spec . console_resource_requirements . clone ( ) ,
686+ replicas : Some ( mz. console_replicas ( ) ) ,
687+ external_certificate_spec : mz. spec . console_external_certificate_spec . clone ( ) ,
688+ pod_annotations : mz. spec . pod_annotations . clone ( ) ,
689+ pod_labels : mz. spec . pod_labels . clone ( ) ,
690+ balancerd : BalancerdRef {
691+ service_name : mz. balancerd_service_name ( ) ,
692+ namespace : mz. namespace ( ) ,
693+ external_certificate_spec : mz
694+ . spec
695+ . balancerd_external_certificate_spec
696+ . clone ( ) ,
697+ authenticator_kind : mz. spec . authenticator_kind ,
698+ } ,
699+ resource_id : Some ( status. resource_id ) ,
700+ } ,
701+ status : None ,
702+ } ;
703+ apply_resource ( & console_api, & console) . await ?;
694704 } else {
695- console . cleanup ( & client , & mz. namespace ( ) ) . await ?;
705+ delete_resource ( & console_api , & mz. name_prefixed ( "console" ) ) . await ?;
696706 }
697707
698708 Ok ( result)
0 commit comments