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 <noreply@anthropic.com>
This commit is contained in:
Prathamesh Musale 2026-03-10 13:12:42 +00:00
parent dcba9e74d9
commit cfbede2ee8
2 changed files with 9 additions and 3 deletions

View File

@ -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.

View File

@ -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, {})