Skip to content

Commit af7df51

Browse files
committed
add: Support for image pull secrets for Ray Cluster images
1 parent 3b41a22 commit af7df51

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/codeflare_sdk/cluster/cluster.py

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def create_app_wrapper(self):
8484
instascale = self.config.instascale
8585
instance_types = self.config.machine_types
8686
env = self.config.envs
87+
pull_secret = self.config.pull_secret
8788
return generate_appwrapper(
8889
name=name,
8990
namespace=namespace,
@@ -98,6 +99,7 @@ def create_app_wrapper(self):
9899
instascale=instascale,
99100
instance_types=instance_types,
100101
env=env,
102+
pull_secret=pull_secret,
101103
)
102104

103105
# creates a new cluster with the provided or default spec

src/codeflare_sdk/cluster/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ class ClusterConfiguration:
4848
instascale: bool = False
4949
envs: dict = field(default_factory=dict)
5050
image: str = "ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103"
51+
pull_secret: dict = field(default_factory=dict)

src/codeflare_sdk/utils/generate_yaml.py

+19
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ def update_image(spec, image):
130130
container["image"] = image
131131

132132

133+
def update_pull_secret(spec, pull_secret):
134+
if pull_secret:
135+
if "imagePullSecrets" not in spec:
136+
spec["imagePullSecrets"] = []
137+
spec["imagePullSecrets"].append(pull_secret)
138+
139+
133140
def update_env(spec, env):
134141
containers = spec.get("containers")
135142
for container in containers:
@@ -167,6 +174,7 @@ def update_nodes(
167174
image,
168175
instascale,
169176
env,
177+
pull_secret,
170178
):
171179
if "generictemplate" in item.keys():
172180
head = item.get("generictemplate").get("spec").get("headGroupSpec")
@@ -182,6 +190,7 @@ def update_nodes(
182190
for comp in [head, worker]:
183191
spec = comp.get("template").get("spec")
184192
update_affinity(spec, appwrapper_name, instascale)
193+
update_pull_secret(spec, pull_secret)
185194
update_image(spec, image)
186195
update_env(spec, env)
187196
if comp == head:
@@ -210,6 +219,7 @@ def generate_appwrapper(
210219
instascale: bool,
211220
instance_types: list,
212221
env,
222+
pull_secret: str,
213223
):
214224
user_yaml = read_template(template)
215225
appwrapper_name, cluster_name = gen_names(name)
@@ -233,6 +243,7 @@ def generate_appwrapper(
233243
image,
234244
instascale,
235245
env,
246+
pull_secret,
236247
)
237248
update_dashboard_route(route_item, cluster_name, namespace)
238249
outfile = appwrapper_name + ".yaml"
@@ -314,6 +325,12 @@ def main(): # pragma: no cover
314325
default="default",
315326
help="Set the kubernetes namespace you want to deploy your cluster to. Default. If left blank, uses the 'default' namespace",
316327
)
328+
parser.add_argument(
329+
"--pull-secret",
330+
required=False,
331+
default="",
332+
help="Set pull secret for a private registry",
333+
)
317334

318335
args = parser.parse_args()
319336
name = args.name
@@ -329,6 +346,7 @@ def main(): # pragma: no cover
329346
instance_types = args.instance_types
330347
namespace = args.namespace
331348
env = {}
349+
pull_secret = args.pull_secret
332350

333351
outfile = generate_appwrapper(
334352
name,
@@ -344,6 +362,7 @@ def main(): # pragma: no cover
344362
instascale,
345363
instance_types,
346364
env,
365+
pull_secret,
347366
)
348367
return outfile
349368

0 commit comments

Comments
 (0)