forked from rh-aiservices-bu/insurance-claim-processing
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters