-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add automated scripts to install M2K and MTA
Signed-off-by: gabriel-farache <[email protected]>
- Loading branch information
1 parent
abb2e15
commit e1b4144
Showing
4 changed files
with
110 additions
and
18 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
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,42 @@ | ||
#!/bin/bash | ||
|
||
if [[ -z "${PRIV_ID_RSA_PATH}" ]]; then | ||
echo 'PRIV_ID_RSA_PATH env variable must be set to the path of the private id_rsa file to use. I.e: ${HOME}/.ssh/id_rsa' | ||
exit -1 | ||
fi | ||
|
||
if [[ -z "${PUB_ID_RSA_PATH}" ]]; then | ||
echo 'PUB_ID_RSA_PATH env variable must be set to the path of the public id_rsa file to use. I.e: ${HOME}/.ssh/id_rsa' | ||
exit -1 | ||
fi | ||
|
||
if [[ -z "${M2K_HELM_REPO}" ]]; then | ||
M2K_HELM_REPO=orchestrator-workflows/move2kube | ||
echo "M2K_HELM_REPO not set, using default helm m2k helm repository ${M2K_HELM_REPO}" | ||
helm repo add orchestrator-workflows https://parodos.dev/serverless-workflows-config | ||
fi | ||
|
||
TARGET_NS=sonataflow-infra | ||
M2K_INSTANCE_NS=move2kube | ||
WORKFLOW_NAME=m2k | ||
oc patch configmap/config-features \ | ||
-n knative-serving \ | ||
--type merge \ | ||
-p '{"data":{"kubernetes.podspec-init-containers": "enabled", "kubernetes.podspec-securitycontext": "enabled"}}' | ||
oc -n ${TARGET_NS} create secret generic sshkeys --from-file=id_rsa=${PRIV_ID_RSA_PATH} --from-file=id_rsa.pub=${PUB_ID_RSA_PATH} | ||
helm install move2kube ${M2K_HELM_REPO} -n ${TARGET_NS} --set instance.namespace=${M2K_INSTANCE_NS} | ||
if [ $? -ne 0 ]; then | ||
echo "move2kube chart already installed, run helm delete move2kube -n ${TARGET_NS} to remove it" | ||
exit -1 | ||
fi | ||
oc -n ${TARGET_NS} adm policy add-scc-to-user $(oc -n ${TARGET_NS} get deployments m2k-save-transformation-func-v1-deployment -oyaml | oc adm policy scc-subject-review --no-headers -o yaml --filename - | yq -r .status.allowedBy.name) -z default | ||
oc -n ${M2K_INSTANCE_NS} adm policy add-scc-to-user $(oc -n ${M2K_INSTANCE_NS} get deployments move2kube -oyaml | oc adm policy scc-subject-review --no-headers -o yaml --filename - | yq -r .status.allowedBy.name) -z default | ||
oc -n ${M2K_INSTANCE_NS} create secret generic sshkeys --from-file=id_rsa=${PRIV_ID_RSA_PATH} --from-file=id_rsa.pub=${PUB_ID_RSA_PATH} | ||
oc -n ${M2K_INSTANCE_NS} scale deploy move2kube --replicas=0 && oc -n ${M2K_INSTANCE_NS} scale deploy move2kube --replicas=1 | ||
M2K_ROUTE=$(oc -n ${M2K_INSTANCE_NS} get routes move2kube-route -o yaml | yq -r .spec.host) | ||
oc -n ${TARGET_NS} delete ksvc m2k-save-transformation-func | ||
helm upgrade move2kube ${M2K_HELM_REPO} -n ${TARGET_NS} --set workflow.move2kubeURL=https://${M2K_ROUTE} | ||
|
||
oc -n ${TARGET_NS} patch secret "${WORKFLOW_NAME}-creds" --type merge -p '{"data": { "NOTIFICATIONS_BEARER_TOKEN": "'$(oc get secrets -n rhdh-operator backstage-backend-auth-secret -o go-template='{{ .data.BACKEND_SECRET }}')'"}}' | ||
BROKER_URL=$(oc -n ${TARGET_NS} get broker -o yaml | yq -r .items[0].status.address.url) | ||
oc -n ${TARGET_NS} patch sonataflow m2k --type merge -p '{"spec": { "podTemplate": { "container": { "env": [{"name": "K_SINK", "value": "'${BROKER_URL}'"}, {"name": "MOVE2KUBE_URL", "value": "https://'${M2K_ROUTE}'"}]}}}}' |
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
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,18 @@ | ||
#!/bin/bash | ||
TARGET_NS=sonataflow-infra | ||
|
||
if [[ -z "${MTA_HELM_REPO}" ]]; then | ||
MTA_HELM_REPO=orchestrator-workflows/mta-v7 | ||
echo "MTA_HELM_REPO not set, using default helm mta v7 helm repository ${MTA_HELM_REPO}" | ||
helm repo add orchestrator-workflows https://parodos.dev/serverless-workflows-config | ||
fi | ||
|
||
helm install mta ${MTA_HELM_REPO} -n ${TARGET_NS} | ||
WORKFLOW_NAME=mta-analysis-v7 | ||
oc -n ${TARGET_NS} patch secret "${WORKFLOW_NAME}-creds" --type merge -p '{"data": { "NOTIFICATIONS_BEARER_TOKEN": "'$(oc get secrets -n rhdh-operator backstage-backend-auth-secret -o go-template='{{ .data.BACKEND_SECRET }}')'"}}' | ||
while [[ $retry_count -lt 5 ]]; do | ||
oc -n openshift-mta get route mta && break || sleep 60 | ||
retry_count=$((retry_count + 1)) | ||
done | ||
MTA_ROUTE=$(oc -n openshift-mta get route mta -o yaml | yq -r .spec.host) | ||
oc -n ${TARGET_NS} patch sonataflow mta-analysis-v7 --type merge -p '{"spec": { "podTemplate": { "container": { "env": [{"name": "MTA_URL", "value": "https://'${MTA_ROUTE}'"}]}}}}' |