Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/stack/deploy/k8s/deploy_k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,14 @@ def up(self, detach, skip_cluster_management, services):
namespace = client.V1Namespace(
metadata=client.V1ObjectMeta(name=self.k8s_namespace)
)
self.core_api.create_namespace(body=namespace)
log_debug(f"Namespace {self.k8s_namespace} created")
try:
self.core_api.create_namespace(body=namespace)
log_debug(f"Namespace {self.k8s_namespace} created")
except client.exceptions.ApiException as e:
if e.status == 409:
log_debug(f"Namespace {self.k8s_namespace} already exists")
else:
raise

self._create_volume_data()
self._create_deployments()
Expand Down Expand Up @@ -339,11 +345,12 @@ def down(self, timeout, volumes, skip_cluster_management): # noqa: C901
else:
log_debug("No ingress to delete")

try:
self.core_api.delete_namespace(name=self.k8s_namespace)
log_debug(f"Namespace {self.k8s_namespace} deleted")
except client.exceptions.ApiException as e:
_check_delete_exception(e)
if volumes:
try:
self.core_api.delete_namespace(name=self.k8s_namespace)
log_debug(f"Namespace {self.k8s_namespace} deleted")
except client.exceptions.ApiException as e:
_check_delete_exception(e)

if self.is_kind() and not self.skip_cluster_management:
# Destroy the kind cluster
Expand Down
Loading