btrix helper: Add -microk8s flag to explicitly use microk8s (#888)

This commit is contained in:
Tessa Walsh 2023-05-30 18:41:26 -04:00 committed by GitHub
parent 00fb8ac048
commit 08b3d706a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

29
btrix
View File

@ -5,9 +5,6 @@
# Note: btrix helper expects a local.yaml file to exist in # Note: btrix helper expects a local.yaml file to exist in
# the chart directory alongside values.yaml. # the chart directory alongside values.yaml.
# #
# The utility will check if microk8s is installed and if so
# will preface all helm and kubectl commands with microk8s.
#
# Test commands require installing pytest first, e.g.: # Test commands require installing pytest first, e.g.:
# python3 -m pip install pytest # python3 -m pip install pytest
# #
@ -16,11 +13,13 @@
# $ ./btrix bootstrap # $ ./btrix bootstrap
# Build frontend and backend and upgrade # Build frontend and backend and upgrade
# Optional args: # Optional args:
# -microk8s: Preface kubectl/helm commands with microk8s
# -wait: Wait until pods are ready # -wait: Wait until pods are ready
# #
# $ ./btrix reset # $ ./btrix reset
# Uinstall, delete data, then bootstrap # Uinstall, delete data, then bootstrap
# Optional args: # Optional args:
# -microk8s: Preface kubectl/helm commands with microk8s
# -wait: Wait until pods are ready # -wait: Wait until pods are ready
# #
# $ ./btrix test # $ ./btrix test
@ -49,7 +48,7 @@ bootstrapMicrok8s(){
./scripts/build-frontend.sh ./scripts/build-frontend.sh
echo "Installing..." echo "Installing..."
microk8s helm upgrade --install -f ./chart/values.yaml -f ./chart/local.yaml btrix ./chart microk8s helm3 upgrade --install -f ./chart/values.yaml -f ./chart/local.yaml btrix ./chart
} }
waitUntilReady(){ waitUntilReady(){
@ -88,13 +87,9 @@ runNightlyTests() {
python3 -m pytest backend/test_nightly/*.py python3 -m pytest backend/test_nightly/*.py
} }
microk8s=false
CONTEXT=$(cat ~/.kube/config | grep "current-context:" | sed "s/current-context: //") CONTEXT=$(cat ~/.kube/config | grep "current-context:" | sed "s/current-context: //")
MICROK8S="-microk8s"
if [[ $(microk8s) ]]; then WAIT="-wait"
microk8s=true
fi
# bootstrap: build frontend and backend, upgrade and wait until ready # bootstrap: build frontend and backend, upgrade and wait until ready
if [[ $1 = "bootstrap" ]]; then if [[ $1 = "bootstrap" ]]; then
@ -108,15 +103,15 @@ if [[ $1 = "bootstrap" ]]; then
exit 1 exit 1
fi fi
if [[ $2 = "$MICROK8S" || $3 = "$MICROK8S" ]] ; then
if [ "$microk8s" = true ] ; then
bootstrapMicrok8s bootstrapMicrok8s
else else
bootstrap bootstrap
fi fi
if [[ $2 = "-wait" ]]; then
if [ "$microk8s" = true ] ; then if [[ $2 = "$WAIT" || $3 = "$WAIT" ]]; then
if [[ $2 = "$MICROK8S" || $3 = "$MICROK8S" ]] ; then
waitUntilReadyMicrok8s waitUntilReadyMicrok8s
else else
waitUntilReady waitUntilReady
@ -136,7 +131,7 @@ if [[ $1 = "reset" ]]; then
exit 1 exit 1
fi fi
if [ "$microk8s" = true ] ; then if [[ $2 = "$MICROK8S" || $3 = "$MICROK8S" ]] ; then
resetMicrok8s resetMicrok8s
bootstrapMicrok8s bootstrapMicrok8s
else else
@ -144,8 +139,8 @@ if [[ $1 = "reset" ]]; then
bootstrap bootstrap
fi fi
if [[ $2 = "-wait" ]]; then if [[ $2 = "$WAIT" || $3 = "$WAIT" ]] ; then
if [ "$microk8s" = true ] ; then if [[ $2 = "$MICROK8S" || $3 = "$MICROK8S" ]] ; then
waitUntilReadyMicrok8s waitUntilReadyMicrok8s
else else
waitUntilReady waitUntilReady