diff --git a/modules/python/clients/kubernetes_client.py b/modules/python/clients/kubernetes_client.py index a564c503f9..4d4240f349 100644 --- a/modules/python/clients/kubernetes_client.py +++ b/modules/python/clients/kubernetes_client.py @@ -175,12 +175,13 @@ def delete_namespace(self, namespace): return self.api.delete_namespace(namespace) # TODO: Explore https://kustomize.io for templating - def create_template(self, template_path: str, replacements: dict) -> str: + def create_template(self, template_path: str, replacements: dict, *, log_template: bool = True) -> str: """ Generate a Kubernetes resource template by replacing placeholders with actual values. :param template_path: Path to the YAML template file. :param replacements: Dictionary of placeholders and their corresponding values. + :param log_template: Whether to log the template content. :return: Processed YAML content as a string. """ if not os.path.isfile(template_path): @@ -192,7 +193,8 @@ def create_template(self, template_path: str, replacements: dict) -> str: for key, value in replacements.items(): template = template.replace(f"{{{{{key}}}}}", str(value)) - logger.info(f"Final template: \n{template}") + if log_template: + logger.info(f"Final template: \n{template}") return template except Exception as e: diff --git a/modules/python/kwok/kwok.py b/modules/python/kwok/kwok.py index 26a9cde834..c815619180 100644 --- a/modules/python/kwok/kwok.py +++ b/modules/python/kwok/kwok.py @@ -111,6 +111,7 @@ class Node(KWOK): node_pods: str = "110" node_gpu: str = "0" enable_dra: bool = False + print_node_yaml: bool = True def create(self): try: @@ -137,7 +138,7 @@ def create(self): "node_gpu": self.node_gpu } kwok_template = self.k8s_client.create_template( - self.node_manifest_path, replacements + self.node_manifest_path, replacements, log_template=self.print_node_yaml ) execute_with_retries( self.k8s_client.create_node, @@ -317,6 +318,12 @@ def main(): parser = argparse.ArgumentParser( description="KWOK: Kubernetes WithOut Kubelet - Virtual Node/Pod Simulator" ) + parser.add_argument( + "--mute-node-creation", + dest="print_node_yaml", + action="store_false", + help="Mute only the Node YAML during creation; other logs are unchanged.", + ) parser.add_argument( "--node-count", type=int, @@ -388,6 +395,7 @@ def main(): kwok_release=args.kwok_release, enable_metrics=args.enable_metrics, enable_dra=args.enable_dra, + print_node_yaml=args.print_node_yaml, ) if args.action == "create": node.create()