Skip to content

Commit

Permalink
fix: fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
DiCanio committed Mar 18, 2024
1 parent bc4a3c1 commit 06d7d7e
Showing 1 changed file with 18 additions and 54 deletions.
72 changes: 18 additions & 54 deletions k8s/deploy-to-minikube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,77 +27,51 @@ if [[ -z "${AUTH_JWKS_URL}" || -z "${HUB_AUTH_ROBOT_ID}" || -z "${ROBOT_SECRET}"
exit 1
fi

checkSuccessOrFailWithCode() {
if [ $1 -ne 0 ]; then
echo "FAILED"
exit $2
else
echo "OK"
fi
}

echo -n "Creating temporary working directory..."
WORK_DIR=`mktemp -d -p "${BASE_DIR}"`
if [ $? -ne 0 ]; then
echo "FAILED"
exit 2
else
echo "OK"
fi
checkSuccessOrFailWithCode $? 2

echo -n "Copying k8s manifest files..."
for f in "${BASE_DIR}"/manifests/*.yml; do
cp "${f}" "${WORK_DIR}"
done
if [ $? -ne 0 ]; then
echo "FAILED"
exit 3
else
echo "OK"
fi
checkSuccessOrFailWithCode $? 3

echo -n "Preparing broker deployment..."
sed -i -e "s#<AUTH_JWKS_URL>#${AUTH_JWKS_URL}#" \
-e "s#<HUB_AUTH_ROBOT_ID>#${HUB_AUTH_ROBOT_ID}#" \
-e "s#<HUB_AUTH_BASE_URL>#${HUB_AUTH_BASE_URL:-"https://auth.privateaim.net"}#" \
-e "s#<HUB_BASE_URL>#${HUB_BASE_URL:-"https://api.privateaim.net"}#" \
"${WORK_DIR}/broker-deployment.yml"
if [ $? -ne 0 ]; then
echo "FAILED"
exit 4
else
echo "OK"
fi
checkSuccessOrFailWithCode $? 4

echo -n "Preparing hub auth secret..."
sed -i -e "s#<ROBOT_SECRET>#$(echo -n ${ROBOT_SECRET} | base64)#" \
"${WORK_DIR}/hub-auth-secret.yml"
if [ $? -ne 0 ]; then
echo "FAILED"
exit 5
else
echo "OK"
fi
checkSuccessOrFailWithCode $? 5

echo -n "Preparing ingress..."
sed -i -e "s#<NODE_MESSAGE_BROKER_HOST>#${NODE_MESSAGE_BROKER_HOST}#" \
"${WORK_DIR}/ingress.yml"
if [ $? -ne 0 ]; then
echo "FAILED"
exit 6
else
echo "OK"
fi
checkSuccessOrFailWithCode $? 6


echo -n "Deleting previous image..."
minikube image rm docker.io/flame/node-message-broker:latest >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "FAILED"
exit 7
else
echo "OK"
fi
checkSuccessOrFailWithCode $? 7

echo -n "Creating Docker image..."
minikube image build -t docker.io/flame/node-message-broker:latest "${BASE_DIR}/.." >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "FAILED"
exit 8
else
echo "OK"
fi
checkSuccessOrFailWithCode $? 8

echo -n "Applying manifest files..."
# TODO: make namespace adjustable!!!
Expand All @@ -107,18 +81,8 @@ minikube kubectl -- --namespace "${NAMESPACE}" apply -f "${WORK_DIR}/hub-auth-se
-f "${WORK_DIR}/broker-service.yml" \
-f "${WORK_DIR}/broker-deployment.yml" \
-f "${WORK_DIR}/ingress.yml" >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "FAILED"
exit 9
else
echo "OK"
fi
checkSuccessOrFailWithCode $? 9

echo -n "Deleting temporary working directory..."
rm -Rf "${WORK_DIR}"
if [ $? -ne 0 ]; then
echo "FAILED"
exit 10
else
echo "OK"
fi
checkSuccessOrFailWithCode $? 10

0 comments on commit 06d7d7e

Please sign in to comment.