Skip to content

Commit

Permalink
add enablemodelcar as presync
Browse files Browse the repository at this point in the history
  • Loading branch information
guimou committed Oct 22, 2024
1 parent 34d5ad9 commit 3b02cb4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
57 changes: 57 additions & 0 deletions bootstrap/ic-shared-llm/job-enable-modelcar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
apiVersion: batch/v1
kind: Job
metadata:
name: patch-inferenceservice-config-bck
namespace: rhods-notebooks
annotations:
argocd.argoproj.io/sync-wave: "0"
argocd.argoproj.io/hook: PreSync
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
spec:
backoffLimit: 4
template:
spec:
serviceAccount: modelcar-enable-sa
serviceAccountName: modelcar-enable-sa
containers:
- name: patch-configmap
image: registry.redhat.io/openshift4/ose-cli:v4.15.0
command: ["/bin/sh", "-c"]
args:
- |
# Wait for the inferenceservice-config configmap to be available
echo "Waiting for the inferenceservice-config configmap to be available..."
until oc get configmap -n redhat-ods-applications inferenceservice-config; do
echo "inferenceservice-configmap not available retrying in 10s..."
sleep 10
done
echo "Ready to proceed!"
# Fetch current storageInitializer config
config=$(oc get configmap inferenceservice-config -n redhat-ods-applications -o jsonpath='{.data.storageInitializer}')
# Check if "enableModelcar" is already enabled
if echo "$config" | grep '"enableModelcar": false'; then
echo "Patching configmap to enable modelcar..."
# Modify the config to enable modelcar using sed
newValue=$(echo "$config" | sed 's/"enableModelcar": false/"enableModelcar": true/')
newValueEscaped=$(echo "$newValue" | sed 's/\"/\\\"/g')
# Patch the configmap with the new value
oc patch configmap inferenceservice-config -n redhat-ods-applications --type='json' -p "[{\"op\": \"replace\", \"path\": \"/data/storageInitializer\", \"value\": \"$newValueEscaped\"}]"
else
echo "Modelcar is already enabled, no patching needed."
fi
# Restart the KServe controller to apply changes
oc delete pod -n redhat-ods-applications -l control-plane=kserve-controller-manager
# Wait for the KServe controller to be ready
echo "Waiting for the KServe controller to be ready..."
until oc get pod -n redhat-ods-applications -l control-plane=kserve-controller-manager -o jsonpath='{.items[0].status.containerStatuses[0].ready}' | grep -q true; do
echo "KServe controller not ready retrying in 10s..."
sleep 10
done
restartPolicy: OnFailure
1 change: 1 addition & 0 deletions bootstrap/ic-shared-llm/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ commonLabels:

resources:
# wave 0
- job-enable-modelcar.yaml
- namespace.yaml
# wave 1
- serving-runtime-vllm-granite-modelcar.yaml
Expand Down

0 comments on commit 3b02cb4

Please sign in to comment.