Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Kubernetes default resources configurable #1800

Merged
merged 5 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions metaflow/metaflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@
KUBERNETES_SHARED_MEMORY = from_conf("KUBERNETES_SHARED_MEMORY", None)
# Default port number to open on the pods
KUBERNETES_PORT = from_conf("KUBERNETES_PORT", None)
# Default kubernetes resource requests for CPU, memory and disk
KUBERNETES_RESOURCES = from_conf("KUBERNETES_RESOURCES", "")

ARGO_WORKFLOWS_KUBERNETES_SECRETS = from_conf("ARGO_WORKFLOWS_KUBERNETES_SECRETS", "")
ARGO_WORKFLOWS_ENV_VARS_TO_SKIP = from_conf("ARGO_WORKFLOWS_ENV_VARS_TO_SKIP", "")
Expand Down
9 changes: 9 additions & 0 deletions metaflow/plugins/kubernetes/kubernetes_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
KUBERNETES_SERVICE_ACCOUNT,
KUBERNETES_SHARED_MEMORY,
KUBERNETES_PORT,
KUBERNETES_RESOURCES,
)
from metaflow.plugins.resources_decorator import ResourcesDecorator
from metaflow.plugins.timeout_decorator import get_run_time_limit_for_task
Expand Down Expand Up @@ -174,6 +175,14 @@ def __init__(self, attributes=None, statically_defined=False):
except (NameError, ImportError):
pass

# parse the CPU, memory, disk, values from the KUBERNETES_RESOURCES environment variable (you would need to export the METAFLOW_KUBERNETES_RESOURCES environment variable with the desired values before running the flow)
# find the values in the format "cpu=1,memory=4096,disk=10240", if not set, the default values described above are used
if KUBERNETES_RESOURCES:
martinhausio marked this conversation as resolved.
Show resolved Hide resolved
for resource in KUBERNETES_RESOURCES.split(","):
key, value = resource.split("=")
if key in self.attributes:
self.attributes[key] = value

# If no docker image is explicitly specified, impute a default image.
if not self.attributes["image"]:
# If metaflow-config specifies a docker image, just use that.
Expand Down