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

Add option for resources limits #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions contents/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,16 @@ def create_pod_template_spec(data):
requests=tmp_resources
)

if "resources_limits" in data:
resources_array = data["resources_limits"].split(",")
tmp_limits = dict(s.split('=', 1) for s in resources_array)
if container.resources is not None:
container.resources.limits = tmp_limits
else:
container.resources = client.V1ResourceRequirements(
limits=tmp_limits
)

template_spec = client.V1PodSpec(
containers=[container]
)
Expand Down
4 changes: 4 additions & 0 deletions contents/deployment-create.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def main():
rr = os.environ.get('RD_CONFIG_RESOURCES_REQUESTS')
data["resources_requests"] = rr

if os.environ.get('RD_CONFIG_RESOURCES_LIMITS'):
rl = os.environ.get('RD_CONFIG_RESOURCES_LIMITS')
data["resources_limits"] = rl

if os.environ.get('RD_CONFIG_ANNOTATIONS'):
data["annotations"] = os.environ.get('RD_CONFIG_ANNOTATIONS')

Expand Down
8 changes: 8 additions & 0 deletions contents/deployment-update.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ def create_deployment_object(data):
requests=tmp_resources
)

if "resources_limits" in data:
resources_array = data["resources_limits"].split(",")
tmp = dict(s.split('=', 1) for s in resources_array)
if container.resources is not None:
container.resources.limits = tmp
else:
container.resources = client.V1ResourceRequirements(limits=tmp)

labels = None
if "labels" in data:
labels_array = data["labels"].split(',')
Expand Down
12 changes: 12 additions & 0 deletions contents/job-create.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ def create_job_object(data):
requests=tmp
)

if "resources_limits" in data:
resources_array = data["resources_limits"].split(",")
tmp = dict(s.split('=', 1) for s in resources_array)
if container.resources is not None:
container.resources.limits = tmp
else:
container.resources = client.V1ResourceRequirements(limits=tmp)

if "volume_mounts" in data:
mounts = common.create_volume_mount_yaml(data)
container.volume_mounts = mounts
Expand Down Expand Up @@ -241,6 +249,10 @@ def main():
if os.environ.get('RD_CONFIG_RESOURCES_REQUESTS'):
req = os.environ.get('RD_CONFIG_RESOURCES_REQUESTS')
data["resources_requests"] = req

if os.environ.get('RD_CONFIG_RESOURCES_LIMITS'):
lim = os.environ.get('RD_CONFIG_RESOURCES_LIMITS')
data["resources_limits"] = lim

if os.environ.get('RD_CONFIG_VOLUME_MOUNTS'):
data["volume_mounts"] = os.environ.get('RD_CONFIG_VOLUME_MOUNTS')
Expand Down
4 changes: 4 additions & 0 deletions contents/pods-create.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def main():
if os.environ.get('RD_CONFIG_RESOURCES_REQUESTS'):
rr = os.environ.get('RD_CONFIG_RESOURCES_REQUESTS')
data["resources_requests"] = rr

if os.environ.get('RD_CONFIG_RESOURCES_LIMITS'):
rl = os.environ.get('RD_CONFIG_RESOURCES_LIMITS')
data["resources_limits"] = rl

if os.environ.get('RD_CONFIG_WAITREADY'):
data["waitready"] = os.environ.get('RD_CONFIG_WAITREADY')
Expand Down
28 changes: 28 additions & 0 deletions plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,13 @@ providers:
required: false
renderingOptions:
groupName: Container
- name: resources_limits
type: String
title: "Resource Limits"
description: "Limit resources in format cpu=4,memory=1Gi"
required: false
renderingOptions:
groupName: Container
- name: volume_mounts
type: String
title: "Volume Mounts"
Expand Down Expand Up @@ -601,6 +608,13 @@ providers:
required: false
renderingOptions:
groupName: Container
- name: resources_limits
type: String
title: "Resource Limits"
description: "Limit resources in format cpu=4,memory=1Gi"
required: false
renderingOptions:
groupName: Container
- name: config_file
type: String
title: "Kubernetes Config File Path"
Expand Down Expand Up @@ -1789,6 +1803,13 @@ providers:
required: false
renderingOptions:
groupName: Container
- name: resources_limits
type: String
title: "Resource Limits"
description: "Limit resources in format cpu=4,memory=1Gi"
required: false
renderingOptions:
groupName: Container
- name: volumes
type: String
title: "Volumes"
Expand Down Expand Up @@ -2326,6 +2347,13 @@ providers:
required: false
renderingOptions:
groupName: Container
- name: resources_limits
type: String
title: "Resource Limits"
description: "Limit resources in format cpu=4,memory=1Gi"
required: false
renderingOptions:
groupName: Container
- name: volume_mounts
type: String
title: "Volume Mounts"
Expand Down