Skip to content

Commit 0f09a1d

Browse files
authored
read default k8s namespace from config (#823)
1 parent ddc2009 commit 0f09a1d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

metaflow/metaflow_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def from_conf(name, default=None):
173173
# Kubernetes configuration
174174
###
175175
# Kubernetes namespace to use for all objects created by Metaflow
176-
KUBERNETES_NAMESPACE = from_conf("METAFLOW_KUBERNETES_NAMESPACE")
176+
KUBERNETES_NAMESPACE = from_conf("METAFLOW_KUBERNETES_NAMESPACE", "default")
177177
# Service account to use by K8S jobs created by Metaflow
178178
KUBERNETES_SERVICE_ACCOUNT = from_conf("METAFLOW_KUBERNETES_SERVICE_ACCOUNT")
179179
# Default container image for K8S

metaflow/plugins/aws/eks/kubernetes_client.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@ def __init__(self, client_wrapper, **kwargs):
107107
self._client_wrapper = client_wrapper
108108
self._kwargs = kwargs
109109

110-
# Kubernetes namespace defaults to `default`
111-
self._kwargs["namespace"] = self._kwargs["namespace"] or "default"
112-
113110
def create(self):
114111
# Check that job attributes are sensible.
115112

metaflow/plugins/aws/eks/kubernetes_decorator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
KUBERNETES_CONTAINER_IMAGE,
1212
KUBERNETES_CONTAINER_REGISTRY,
1313
DATASTORE_LOCAL_DIR,
14+
KUBERNETES_NAMESPACE,
1415
)
1516
from metaflow.plugins import ResourcesDecorator
1617
from metaflow.plugins.timeout_decorator import get_run_time_limit_for_task
@@ -78,6 +79,8 @@ def my_step(self):
7879
def __init__(self, attributes=None, statically_defined=False):
7980
super(KubernetesDecorator, self).__init__(attributes, statically_defined)
8081

82+
if not self.attributes["namespace"]:
83+
self.attributes["namespace"] = KUBERNETES_NAMESPACE
8184
# TODO: Unify the logic with AWS Batch
8285
# If no docker image is explicitly specified, impute a default image.
8386
if not self.attributes["image"]:

0 commit comments

Comments
 (0)