From cfbede2ee80bc0ed982dd95cc2034a5f723e2dd0 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 10 Mar 2026 13:12:42 +0000 Subject: [PATCH] Support namespace and kind-cluster-name overrides in spec Add optional 'namespace' and 'kind-cluster-name' fields to spec files. When 'namespace' is set, SO uses it instead of deriving one from the cluster-id. When 'kind-cluster-name' is set, SO uses it for the kube context instead of the cluster-id. Together these allow multiple stacks with different cluster-ids (unique resource names) to share a namespace and kind cluster. Co-Authored-By: Claude Opus 4.6 --- stack_orchestrator/deploy/k8s/deploy_k8s.py | 6 +++--- stack_orchestrator/deploy/spec.py | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/stack_orchestrator/deploy/k8s/deploy_k8s.py b/stack_orchestrator/deploy/k8s/deploy_k8s.py index 9ad61838..d9acf672 100644 --- a/stack_orchestrator/deploy/k8s/deploy_k8s.py +++ b/stack_orchestrator/deploy/k8s/deploy_k8s.py @@ -122,9 +122,9 @@ class K8sDeployer(Deployer): return self.deployment_dir = deployment_context.deployment_dir self.deployment_context = deployment_context - self.kind_cluster_name = compose_project_name - # Use deployment-specific namespace for resource isolation and easy cleanup - self.k8s_namespace = f"laconic-{compose_project_name}" + self.kind_cluster_name = deployment_context.spec.get_kind_cluster_name() or compose_project_name + # Use spec namespace if provided, otherwise derive from cluster-id + self.k8s_namespace = deployment_context.spec.get_namespace() or f"laconic-{compose_project_name}" self.cluster_info = ClusterInfo() # stack.name may be an absolute path (from spec "stack:" key after # path resolution). Extract just the directory basename for labels. diff --git a/stack_orchestrator/deploy/spec.py b/stack_orchestrator/deploy/spec.py index e77b9581..effb4981 100644 --- a/stack_orchestrator/deploy/spec.py +++ b/stack_orchestrator/deploy/spec.py @@ -152,6 +152,12 @@ class Spec: def get_http_proxy(self): return self.obj.get(constants.network_key, {}).get(constants.http_proxy_key, []) + def get_namespace(self): + return self.obj.get("namespace") + + def get_kind_cluster_name(self): + return self.obj.get("kind-cluster-name") + def get_annotations(self): return self.obj.get(constants.annotations_key, {})