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