From 9ae45188c3cb799b3a29cb48d36e68803b992c99 Mon Sep 17 00:00:00 2001
From: Pasquale Minervini
Date: Wed, 13 Dec 2023 14:05:35 +0000
Subject: [PATCH 1/2] fix https://github.com/AntreasAntoniou/kubejobs/issues/8
---
kubejobs/jobs.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kubejobs/jobs.py b/kubejobs/jobs.py
index aac9221..199dd89 100644
--- a/kubejobs/jobs.py
+++ b/kubejobs/jobs.py
@@ -115,6 +115,7 @@ def __init__(
user_email: Optional[str] = None,
labels: Optional[dict] = None,
annotations: Optional[dict] = None,
+ namespace: Optional[str] = None
):
self.name = name
@@ -176,6 +177,8 @@ def __init__(
logger.info(f"labels {self.labels}")
logger.info(f"annotations {self.annotations}")
+ self.namespace = namespace
+
def _add_shm_size(self, container: dict):
"""Adds shared memory volume if shm_size is set."""
if self.shm_size:
@@ -319,6 +322,9 @@ def generate_yaml(self):
if self.job_deadlineseconds:
job["spec"]["activeDeadlineSeconds"] = self.job_deadlineseconds
+ if self.namespace:
+ job["metadata"]["namespace"] = self.namespace
+
if not (
self.gpu_type is None
or self.gpu_limit is None
From 7f96198bcceba9eb7798820f45fc05fe04ce38c9 Mon Sep 17 00:00:00 2001
From: Pasquale Minervini
Date: Wed, 13 Dec 2023 14:06:44 +0000
Subject: [PATCH 2/2] fix https://github.com/AntreasAntoniou/kubejobs/issues/8
---
kubejobs/jobs.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/kubejobs/jobs.py b/kubejobs/jobs.py
index 199dd89..960649e 100644
--- a/kubejobs/jobs.py
+++ b/kubejobs/jobs.py
@@ -86,6 +86,7 @@ class KubernetesJob:
secret_env_vars (dict, optional): Dictionary of secret environment variables. Defaults to None.
env_vars (dict, optional): Dictionary of normal (non-secret) environment variables. Defaults to None.
volume_mounts (dict, optional): Dictionary of volume mounts. Defaults to None.
+ namespace (str, optional): Namespace of the job. Defaults to None.
Methods:
generate_yaml() -> dict: Generate the Kubernetes Job YAML configuration.