Skip to content

Commit 4552dce

Browse files
authored
Updated default head node specs and MY_POD_IP env (#25)
* Updated default head node specs and my_pod_ip env * Uniform default
1 parent 8ba6e54 commit 4552dce

File tree

2 files changed

+14
-37
lines changed

2 files changed

+14
-37
lines changed

src/codeflare_sdk/templates/new-template.yaml

+5-32
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ spec:
1717
- replicas: 1
1818
requests:
1919
cpu: 2
20-
memory: 12G
20+
memory: 8G
2121
nvidia.com/gpu: 0
2222
limits:
2323
cpu: 2
24-
memory: 12G
24+
memory: 8G
2525
nvidia.com/gpu: 0
2626
- replicas: 3
2727
requests:
@@ -116,22 +116,6 @@ spec:
116116
# The Ray head pod
117117
- name: ray-head
118118
image: rayproject/ray:latest
119-
env:
120-
- name: AWS_ACCESS_KEY_ID
121-
valueFrom:
122-
secretKeyRef:
123-
name: s3-creds
124-
key: AWS_ACCESS_KEY_ID
125-
- name: AWS_SECRET_ACCESS_KEY
126-
valueFrom:
127-
secretKeyRef:
128-
name: s3-creds
129-
key: AWS_SECRET_ACCESS_KEY
130-
- name: ENDPOINT_URL
131-
valueFrom:
132-
secretKeyRef:
133-
name: s3-creds
134-
key: ENDPOINT_URL
135119
imagePullPolicy: Always
136120
ports:
137121
- containerPort: 6379
@@ -202,21 +186,10 @@ spec:
202186
- 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'
203187
image: rayproject/ray:latest
204188
env:
205-
- name: AWS_ACCESS_KEY_ID
206-
valueFrom:
207-
secretKeyRef:
208-
name: s3-creds
209-
key: AWS_ACCESS_KEY_ID
210-
- name: AWS_SECRET_ACCESS_KEY
211-
valueFrom:
212-
secretKeyRef:
213-
name: s3-creds
214-
key: AWS_SECRET_ACCESS_KEY
215-
- name: ENDPOINT_URL
189+
- name: MY_POD_IP
216190
valueFrom:
217-
secretKeyRef:
218-
name: s3-creds
219-
key: ENDPOINT_URL
191+
fieldRef:
192+
fieldPath: status.podIP
220193
# environment variables to set in the container.Optional.
221194
# Refer to https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/
222195
lifecycle:

src/codeflare_sdk/utils/generate_yaml.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ def update_custompodresources(item, min_cpu, max_cpu, min_memory, max_memory, gp
5050
if 'custompodresources' in item.keys():
5151
custompodresources = item.get('custompodresources')
5252
for i in range(len(custompodresources)):
53+
if i == 0:
54+
# Leave head node resources as template default
55+
continue
5356
resource = custompodresources[i]
5457
for k,v in resource.items():
5558
if k == "replicas" and i == 1:
@@ -90,10 +93,11 @@ def update_image(spec, image):
9093
def update_env(spec, env):
9194
containers = spec.get("containers")
9295
for container in containers:
93-
if not env:
94-
container.pop("env")
95-
else:
96-
container["env"] = env
96+
if env:
97+
if "env" in container:
98+
container["env"].extend(env)
99+
else:
100+
container["env"] = env
97101

98102
def update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, gpu):
99103
container = spec.get("containers")
@@ -126,7 +130,7 @@ def update_nodes(item, appwrapper_name, min_cpu, max_cpu, min_memory, max_memory
126130
update_image(spec, image)
127131
update_env(spec, env)
128132
if comp == head:
129-
update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, 0)
133+
update_resources(spec, 2, 2, 8, 8, 0)
130134
else:
131135
update_resources(spec, min_cpu, max_cpu, min_memory, max_memory, gpu)
132136

0 commit comments

Comments
 (0)