@@ -56,57 +56,48 @@ def get_image(image: str, tag: str | None) -> str:
5656 return f'{ image .rsplit (":" , 1 )[0 ]} :{ tag } '
5757
5858
59- def get_orchestratord_data () -> dict [str , Any ]:
59+ def get_pod_data (
60+ labels : dict [str , str ], namespace = "materialize-environment"
61+ ) -> dict [str , Any ]:
6062 return json .loads (
6163 spawn .capture (
6264 [
6365 "kubectl" ,
6466 "get" ,
6567 "pod" ,
6668 "-l" ,
67- "app.kubernetes.io/instance=operator" ,
69+ "," . join ( f" { key } = { value } " for key , value in labels . items ()) ,
6870 "-n" ,
69- "materialize" ,
71+ namespace ,
7072 "-o" ,
7173 "json" ,
7274 ]
7375 )
7476 )
7577
7678
79+ def get_orchestratord_data () -> dict [str , Any ]:
80+ return get_pod_data (
81+ labels = {"app.kubernetes.io/instance" : "operator" },
82+ namespace = "materialize" ,
83+ )
84+
85+
7786def get_balancerd_data () -> dict [str , Any ]:
78- return json .loads (
79- spawn .capture (
80- [
81- "kubectl" ,
82- "get" ,
83- "pod" ,
84- "-l" ,
85- "app=balancerd" ,
86- "-n" ,
87- "materialize-environment" ,
88- "-o" ,
89- "json" ,
90- ]
91- )
87+ return get_pod_data (
88+ labels = {"materialize.cloud/app" : "balancerd" },
89+ )
90+
91+
92+ def get_console_data () -> dict [str , Any ]:
93+ return get_pod_data (
94+ labels = {"materialize.cloud/app" : "console" },
9295 )
9396
9497
9598def get_environmentd_data () -> dict [str , Any ]:
96- return json .loads (
97- spawn .capture (
98- [
99- "kubectl" ,
100- "get" ,
101- "pod" ,
102- "-l" ,
103- "app=environmentd" ,
104- "-n" ,
105- "materialize-environment" ,
106- "-o" ,
107- "json" ,
108- ]
109- )
99+ return get_pod_data (
100+ labels = {"materialize.cloud/app" : "environmentd" },
110101 )
111102
112103
@@ -528,6 +519,63 @@ def validate(self, mods: dict[type[Modification], Any]) -> None:
528519 ), f"Expected no { expected } in environmentd args, but found it: { args } "
529520
530521
522+ class BalancerdReplicas (Modification ):
523+ @classmethod
524+ def values (cls ) -> list [Any ]:
525+ return [None , 1 , 2 ]
526+
527+ @classmethod
528+ def default (cls ) -> Any :
529+ return None
530+
531+ def modify (self , definition : dict [str , Any ]) -> None :
532+ if self .value is not None :
533+ definition ["materialize" ]["spec" ]["balancerdReplicas" ] = self .value
534+
535+ def validate (self , mods : dict [type [Modification ], Any ]) -> None :
536+ if not mods [BalancerdEnabled ]:
537+ return
538+
539+ def check_replicas ():
540+ balancerd = get_balancerd_data ()
541+ num_pods = len (balancerd ["items" ])
542+ expected = self .value if self .value is not None else 2
543+ assert (
544+ num_pods == expected
545+ ), f"Expected { expected } balancerd pods, but found { num_pods } "
546+
547+ retry (check_replicas , 120 )
548+
549+
550+ class ConsoleReplicas (Modification ):
551+ @classmethod
552+ def values (cls ) -> list [Any ]:
553+ return [None , 1 , 2 ]
554+
555+ @classmethod
556+ def default (cls ) -> Any :
557+ return None
558+
559+ def modify (self , definition : dict [str , Any ]) -> None :
560+ if self .value is not None :
561+ definition ["materialize" ]["spec" ]["consoleReplicas" ] = self .value
562+
563+ def validate (self , mods : dict [type [Modification ], Any ]) -> None :
564+ if not mods [ConsoleEnabled ]:
565+ return
566+
567+ def check_replicas ():
568+ console = get_console_data ()
569+ num_pods = len (console ["items" ])
570+ expected = self .value if self .value is not None else 2
571+ assert (
572+ num_pods == expected
573+ ), f"Expected { expected } console pods, but found { num_pods } "
574+
575+ # console doesn't get launched until last
576+ retry (check_replicas , 120 )
577+
578+
531579def validate_cluster_replica_size (
532580 size : dict [str , Any ], swap_enabled : bool , storage_class_name_set : bool
533581):
@@ -571,24 +619,6 @@ def validate_container_resources(
571619 assert resources ["requests" ]["memory" ] == resources ["limits" ]["memory" ]
572620
573621
574- def get_pod_data (labels : dict [str , str ]) -> dict [str , Any ]:
575- return json .loads (
576- spawn .capture (
577- [
578- "kubectl" ,
579- "get" ,
580- "pod" ,
581- "-l" ,
582- "," .join (f"{ key } ={ value } " for key , value in labels .items ()),
583- "-n" ,
584- "materialize-environment" ,
585- "-o" ,
586- "json" ,
587- ]
588- )
589- )
590-
591-
592622class SwapEnabledGlobal (Modification ):
593623 @classmethod
594624 def values (cls ) -> list [Any ]:
0 commit comments