Skip to content

Updated default head node specs and MY_POD_IP env #25

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

Merged
merged 2 commits into from
Nov 1, 2022
Merged
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
37 changes: 5 additions & 32 deletions src/codeflare_sdk/templates/new-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ spec:
- replicas: 1
requests:
cpu: 2
memory: 12G
memory: 8G
nvidia.com/gpu: 0
limits:
cpu: 2
memory: 12G
memory: 8G
nvidia.com/gpu: 0
- replicas: 3
requests:
Expand Down Expand Up @@ -116,22 +116,6 @@ spec:
# The Ray head pod
- name: ray-head
image: rayproject/ray:latest
env:
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: s3-creds
key: AWS_ACCESS_KEY_ID
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: s3-creds
key: AWS_SECRET_ACCESS_KEY
- name: ENDPOINT_URL
valueFrom:
secretKeyRef:
name: s3-creds
key: ENDPOINT_URL
imagePullPolicy: Always
ports:
- containerPort: 6379
Expand Down Expand Up @@ -202,21 +186,10 @@ spec:
- name: machine-learning # must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc'
image: rayproject/ray:latest
env:
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: s3-creds
key: AWS_ACCESS_KEY_ID
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: s3-creds
key: AWS_SECRET_ACCESS_KEY
- name: ENDPOINT_URL
- name: MY_POD_IP
valueFrom:
secretKeyRef:
name: s3-creds
key: ENDPOINT_URL
fieldRef:
fieldPath: status.podIP
# environment variables to set in the container.Optional.
# Refer to https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/
lifecycle:
Expand Down
14 changes: 9 additions & 5 deletions src/codeflare_sdk/utils/generate_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def update_custompodresources(item, min_cpu, max_cpu, min_memory, max_memory, gp
if 'custompodresources' in item.keys():
custompodresources = item.get('custompodresources')
for i in range(len(custompodresources)):
if i == 0:
# Leave head node resources as template default
continue
resource = custompodresources[i]
for k,v in resource.items():
if k == "replicas" and i == 1:
Expand Down Expand Up @@ -90,10 +93,11 @@ def update_image(spec, image):
def update_env(spec, env):
containers = spec.get("containers")
for container in containers:
if not env:
container.pop("env")
else:
container["env"] = env
if env:
if "env" in container:
container["env"].extend(env)
else:
container["env"] = env

def update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, gpu):
container = spec.get("containers")
Expand Down Expand Up @@ -126,7 +130,7 @@ def update_nodes(item, appwrapper_name, min_cpu, max_cpu, min_memory, max_memory
update_image(spec, image)
update_env(spec, env)
if comp == head:
update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, 0)
update_resources(spec, 2, 2, 8, 8, 0)
else:
update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, gpu)

Expand Down