generated from PrivateAIM/typescript-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [WIP] add deployment script for minikube
- Loading branch information
Showing
5 changed files
with
127 additions
and
14 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 |
---|---|---|
|
@@ -14,3 +14,5 @@ db.sqlite | |
.env | ||
cache | ||
.swc | ||
|
||
k8s/tmp** |
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,110 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Mandatory environment variables: | ||
# | ||
# - AUTH_JWKS_URL | ||
# - HUB_AUTH_ROBOT_ID | ||
# - ROBOT_SECRET | ||
# - NODE_MESSAGE_BROKER_HOST | ||
|
||
BASE_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit 1 ; pwd -P )" | ||
|
||
echo "${AUTH_JWKS_URL}" | ||
echo "${HUB_AUTH_ROBOT_ID}" | ||
echo "${ROBOT_SECRET}" | ||
echo "${NODE_MESSAGE_BROKER_HOST}" | ||
|
||
if [[ -z "${AUTH_JWKS_URL}" || -z "${HUB_AUTH_ROBOT_ID}" || -z "${ROBOT_SECRET}" || -z "${NODE_MESSAGE_BROKER_HOST}" ]]; then | ||
echo "One or more mandatory environment variables are not set!" | ||
echo "Mandatory environment variables are:" | ||
echo "" | ||
echo " - AUTH_JWKS_URL" | ||
echo " - HUB_AUTH_ROBOT_ID" | ||
echo " - ROBOT_SECRET" | ||
echo " - NODE_MESSAGE_BROKER_HOST" | ||
exit 1 | ||
fi | ||
|
||
echo -n "Creating working directory..." | ||
WORK_DIR=`mktemp -d -p "${BASE_DIR}"` | ||
if [ $? -ne 0 ]; then | ||
echo "FAILED" | ||
exit 2 | ||
else | ||
echo "OK" | ||
fi | ||
|
||
echo -n "Copying k8s manifest files..." | ||
for f in "${BASE_DIR}"/*.yml; do | ||
cp "${f}" "${WORK_DIR}" | ||
done | ||
if [ $? -ne 0 ]; then | ||
echo "FAILED" | ||
exit 3 | ||
else | ||
echo "OK" | ||
fi | ||
|
||
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}#" \ | ||
"${WORK_DIR}/broker-deployment.yml" | ||
if [ $? -ne 0 ]; then | ||
echo "FAILED" | ||
exit 4 | ||
else | ||
echo "OK" | ||
fi | ||
|
||
echo -n "Preparing hub auth secret..." | ||
sed -i -e "s#<ROBOT_SECRET>#${ROBOT_SECRET}#" \ | ||
"${WORK_DIR}/hub-auth-secret.yml" | ||
if [ $? -ne 0 ]; then | ||
echo "FAILED" | ||
exit 5 | ||
else | ||
echo "OK" | ||
fi | ||
|
||
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 | ||
|
||
|
||
echo -n "Deleting previous image..." | ||
minikube image rm docker.io/flame/node-message-broker:latest | ||
if [ $? -ne 0 ]; then | ||
echo "FAILED" | ||
exit 7 | ||
else | ||
echo "OK" | ||
fi | ||
|
||
echo -n "Creating Docker image..." | ||
minikube image build -t docker.io/flame/node-message-broker:latest "${BASE_DIR}/.." | ||
if [ $? -ne 0 ]; then | ||
echo "FAILED" | ||
exit 8 | ||
else | ||
echo "OK" | ||
fi | ||
|
||
echo -n "Applying manifest files..." | ||
kubectl --namespace=flame apply -f "${WORK_DIR}/hub-auth-secret.yml" \ | ||
-f "${WORK_DIR}/broker-db-service.yml" \ | ||
-f "${WORK_DIR}/broker-db-statefulset.yml" \ | ||
-f "${WORK_DIR}/broker-service.yml" \ | ||
-f "${WORK_DIR}/broker-deployment.yml" \ | ||
-f "${WORK_DIR}/ingress.yml" | ||
if [ $? -ne 0 ]; then | ||
echo "FAILED" | ||
exit 9 | ||
else | ||
echo "OK" | ||
fi |
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 |
---|---|---|
|
@@ -3,4 +3,4 @@ kind: Secret | |
metadata: | ||
name: hub-auth | ||
data: | ||
robot-secret: ${ROBOT_SECRET} | ||
robot-secret: <ROBOT_SECRET> |
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