Skip to content

Commit c8c0f93

Browse files
authored
Merge pull request #37 from sauagarwa/main
Remove the dependency of minio on RHOAI operator
2 parents d172066 + 6691aec commit c8c0f93

File tree

7 files changed

+63
-70
lines changed

7 files changed

+63
-70
lines changed

charts/all/llm-serving-service/templates/serving-service-setup.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,12 @@ spec:
158158
- -ec
159159
- |-
160160
oc wait --for=condition=complete job/load-model-set -n rag-llm --timeout=10m
161-
sleep 10
161+
162+
echo -n 'Waiting for openshift ai initialize'
163+
while ! oc describe sub rhods-operator -n redhat-ods-operator 2>/dev/null | grep -qF rhods-operator; do
164+
echo -n .
165+
sleep 15
166+
done; echo
162167
command:
163168
- /bin/bash
164169
image: image-registry.openshift-image-registry.svc:5000/openshift/tools:latest
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
hfmodel:
2-
key: secret/data/hub/hfmodel
2+
key: secret/data/hub/hfmodel
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: "external-secrets.io/v1beta1"
2+
kind: ExternalSecret
3+
metadata:
4+
name: minio-secret
5+
namespace: rag-llm
6+
spec:
7+
refreshInterval: 15s
8+
secretStoreRef:
9+
name: {{ .Values.secretStore.name }}
10+
kind: {{ .Values.secretStore.kind }}
11+
dataFrom:
12+
- extract:
13+
key: {{ .Values.minio.key }}

charts/all/minio/templates/setup-minio.yaml

Lines changed: 28 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ spec:
4141
storage: 50Gi
4242
volumeMode: Filesystem
4343
---
44-
kind: Secret
45-
apiVersion: v1
46-
metadata:
47-
name: minio-secret
48-
stringData:
49-
MINIO_ROOT_USER: minio
50-
MINIO_ROOT_PASSWORD: {{ randAlphaNum 10 | b64enc }}
51-
---
5244
kind: Deployment
5345
apiVersion: apps/v1
5446
metadata:
@@ -213,26 +205,32 @@ spec:
213205
- args:
214206
- -ec
215207
- |-
216-
oc get secret minio-secret
217208
env | grep MINIO
209+
pip install minio;
218210
cat << 'EOF' | python3
219-
import boto3, os
220-
221-
s3 = boto3.client("s3",
222-
endpoint_url="http://minio-service:9000",
223-
aws_access_key_id=os.getenv("MINIO_ROOT_USER"),
224-
aws_secret_access_key=os.getenv("MINIO_ROOT_PASSWORD"))
211+
from minio import Minio
212+
import os
213+
client = Minio(
214+
"minio-service:9000",
215+
access_key=os.getenv("MINIO_ROOT_USER"),
216+
secret_key=os.getenv("MINIO_ROOT_PASSWORD"),
217+
secure=False
218+
)
225219
bucket = 'models'
220+
226221
print('creating models bucket')
227-
if bucket not in [bu["Name"] for bu in s3.list_buckets()["Buckets"]]:
228-
s3.create_bucket(Bucket=bucket)
222+
if client.bucket_exists(bucket):
223+
print("bucket 'models' exists")
224+
else:
225+
client.make_bucket(bucket)
226+
print("bucket 'models' created successfully")
229227
EOF
230228
command:
231229
- /bin/bash
232230
envFrom:
233231
- secretRef:
234232
name: minio-secret
235-
image: image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/s2i-generic-data-science-notebook:2024.1
233+
image: registry.access.redhat.com/ubi8/python-38
236234
imagePullPolicy: IfNotPresent
237235
name: create-buckets
238236
initContainers:
@@ -242,22 +240,16 @@ spec:
242240
echo -n 'Waiting for minio root user secret'
243241
while ! oc get secret minio-secret 2>/dev/null | grep -qF minio-secret; do
244242
echo -n .
245-
sleep 15
243+
sleep 5
246244
done; echo
247245
248246
echo -n 'Waiting for minio deployment'
249247
while ! oc get deployment minio 2>/dev/null | grep -qF minio; do
250248
echo -n .
251-
sleep 15
249+
sleep 5
252250
done; echo
253251
oc wait --for=condition=available --timeout=60s deployment/minio
254252
sleep 10
255-
256-
echo -n 'Waiting for openshift ai initialize'
257-
while ! oc describe sub rhods-operator -n redhat-ods-operator 2>/dev/null | grep -qF rhods-operator; do
258-
echo -n .
259-
sleep 15
260-
done; echo
261253
command:
262254
- /bin/bash
263255
image: image-registry.openshift-image-registry.svc:5000/openshift/tools:latest
@@ -291,7 +283,7 @@ spec:
291283
- args:
292284
- -ec
293285
- |-
294-
pip install huggingface_hub;
286+
pip install huggingface_hub boto3;
295287
cat << 'EOF' | python3
296288
import boto3, os, botocore, subprocess
297289
from huggingface_hub import snapshot_download
@@ -352,34 +344,14 @@ spec:
352344
print(obj.key)
353345
354346
if hf_token is not None and hf_token.strip() != "None":
355-
# If 'hftoken' is not None and not empty, execute this code
356-
print("hftoken is set.")
357-
login(token=hf_token)
358-
mistral_models_path = Path.home().joinpath(model_id)
359-
mistral_models_path.mkdir(parents=True, exist_ok=True)
360-
snapshot_download(repo_id="mistralai/" + model_id, allow_patterns=["config.json", "consolidated.safetensors", "generation_config.json", "model*", "special_tokens_map.json", "tokenizer*", "params.json"], local_dir=mistral_models_path)
361-
362-
else:
363-
# If 'hftoken' is None or an empty string, execute this code
364-
print("hftoken is not set or is empty.")
365-
print("Performing default action due to missing hftoken.")
366-
try:
367-
# Step 1: Install Git LFS
368-
run_command("git lfs install")
369-
370-
# Step 2: Clone the specified repository from Hugging Face
371-
run_command("git clone https://huggingface.co/mistral-community/" + model_id)
372-
373-
# Step 3: Remove the .git directory to save space
374-
run_command("rm -rf " + model_id + "/.git")
375-
376-
print("Commands executed successfully.")
377-
378-
except subprocess.CalledProcessError as e:
379-
print(f"An error occurred while running the command: {e}")
347+
# If 'hftoken' is not None and not empty, execute this code
348+
print("hftoken is set.")
349+
login(token=hf_token)
350+
mistral_models_path = Path.home().joinpath(model_id)
351+
mistral_models_path.mkdir(parents=True, exist_ok=True)
352+
snapshot_download(repo_id=modelid, local_dir=mistral_models_path)
380353
381354
list_objects("models")
382-
383355
print(model_id)
384356
num_files = upload_directory_to_s3(model_id, "llm-models/" + model_id)
385357
@@ -396,7 +368,7 @@ spec:
396368
name: minio-secret
397369
- secretRef:
398370
name: huggingface-secret
399-
image: image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/s2i-generic-data-science-notebook:2024.1
371+
image: registry.access.redhat.com/ubi8/python-38
400372
imagePullPolicy: IfNotPresent
401373
name: download-model
402374
initContainers:
@@ -406,26 +378,16 @@ spec:
406378
echo -n 'Waiting for minio root user secret'
407379
while ! oc get secret minio-secret 2>/dev/null | grep -qF minio-secret; do
408380
echo -n .
409-
sleep 15
381+
sleep 5
410382
done; echo
411383
412384
echo -n 'Waiting for minio deployment'
413385
while ! oc get deployment minio 2>/dev/null | grep -qF minio; do
414386
echo -n .
415-
sleep 15
387+
sleep 5
416388
done; echo
417389
oc wait --for=condition=available --timeout=600s deployment/minio
418390
sleep 10
419-
420-
echo -n 'Waiting for openshift ai initialize'
421-
while ! oc describe sub rhods-operator -n redhat-ods-operator 2>/dev/null | grep -qF rhods-operator; do
422-
echo -n .
423-
sleep 15
424-
done; echo
425-
426-
oc wait --for=condition=CatalogSourcesUnhealthy=False subscription/rhods-operator --timeout=600s -n redhat-ods-operator
427-
oc wait --for=jsonpath='{.status.phase}'=Ready --timeout=600s -n redhat-ods-operator dscinitialization/default-dsci
428-
sleep 10
429391
command:
430392
- /bin/bash
431393
image: image-registry.openshift-image-registry.svc:5000/openshift/tools:latest

charts/all/minio/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
secretStore:
2+
name: vault-backend
3+
kind: ClusterSecretStore
4+
5+
minio:
6+
key: secret/data/hub/minio

charts/all/rhods/templates/sub-rhods.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ metadata:
44
name: rhods-operator
55
namespace: redhat-ods-operator
66
spec:
7-
channel: fast
7+
channel: stable
88
installPlanApproval: Manual
99
name: rhods-operator
1010
source: redhat-operators
1111
sourceNamespace: openshift-marketplace
12-
startingCSV: rhods-operator.2.11.0
12+
startingCSV: rhods-operator.2.13.1

values-secret.yaml.template

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ secrets:
1717
value: null
1818
- name: modelId
1919
value: "mistral-community/Mistral-7B-Instruct-v0.3"
20+
- name: minio
21+
fields:
22+
- name: MINIO_ROOT_USER
23+
value: minio
24+
- name: MINIO_ROOT_PASSWORD
25+
value: null
26+
onMissingValue: generate

0 commit comments

Comments
 (0)