Make btrix helper work with microk8s (#768)
* Check for microk8s * Use python3 * Add note about installing pytest * Add chart/local.yaml to .gitignore to avoid committing
This commit is contained in:
parent
821d29bd2a
commit
a9c1c54194
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@
|
|||||||
private.yml
|
private.yml
|
||||||
# microk8s playbook hosts
|
# microk8s playbook hosts
|
||||||
hosts
|
hosts
|
||||||
|
chart/local.yaml
|
||||||
|
67
btrix
67
btrix
@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
# ./btrix: Browsertrix Cloud dev environment utility
|
# ./btrix: Browsertrix Cloud dev environment utility
|
||||||
#
|
#
|
||||||
|
# Note: btrix helper expects a local.yaml file to exist in
|
||||||
|
# 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.:
|
||||||
|
# python3 -m pip install pytest
|
||||||
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
#
|
#
|
||||||
# $ ./btrix bootstrap
|
# $ ./btrix bootstrap
|
||||||
@ -32,11 +41,27 @@ bootstrap(){
|
|||||||
helm upgrade --install -f ./chart/values.yaml -f ./chart/local.yaml btrix ./chart
|
helm upgrade --install -f ./chart/values.yaml -f ./chart/local.yaml btrix ./chart
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bootstrapMicrok8s(){
|
||||||
|
echo "Building backend..."
|
||||||
|
./scripts/build-backend.sh
|
||||||
|
|
||||||
|
echo "Building frontend..."
|
||||||
|
./scripts/build-frontend.sh
|
||||||
|
|
||||||
|
echo "Installing..."
|
||||||
|
microk8s helm upgrade --install -f ./chart/values.yaml -f ./chart/local.yaml btrix ./chart
|
||||||
|
}
|
||||||
|
|
||||||
waitUntilReady(){
|
waitUntilReady(){
|
||||||
echo "Waiting until ready..."
|
echo "Waiting until ready..."
|
||||||
kubectl wait --for=condition=ready pod --all --timeout=300s
|
kubectl wait --for=condition=ready pod --all --timeout=300s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitUntilReadyMicrok8s(){
|
||||||
|
echo "Waiting until ready..."
|
||||||
|
microk8s kubectl wait --for=condition=ready pod --all --timeout=300s
|
||||||
|
}
|
||||||
|
|
||||||
reset(){
|
reset(){
|
||||||
echo "Uninstalling..."
|
echo "Uninstalling..."
|
||||||
helm uninstall btrix
|
helm uninstall btrix
|
||||||
@ -45,44 +70,74 @@ reset(){
|
|||||||
kubectl delete pvc --all
|
kubectl delete pvc --all
|
||||||
}
|
}
|
||||||
|
|
||||||
run_tests() {
|
resetMicrok8s(){
|
||||||
|
echo "Uninstalling..."
|
||||||
|
microk8s helm uninstall btrix
|
||||||
|
|
||||||
|
echo "Deleting data..."
|
||||||
|
microk8s kubectl delete pvc --all
|
||||||
|
}
|
||||||
|
|
||||||
|
runTests() {
|
||||||
echo "Running backend tests..."
|
echo "Running backend tests..."
|
||||||
python -m pytest backend/test/*.py
|
python3 -m pytest backend/test/*.py
|
||||||
}
|
}
|
||||||
|
|
||||||
run_nightly_tests() {
|
runNightlyTests() {
|
||||||
echo "Running nightly backend tests..."
|
echo "Running nightly backend tests..."
|
||||||
python -m pytest backend/test_nightly/*.py
|
python3 -m pytest backend/test_nightly/*.py
|
||||||
}
|
}
|
||||||
|
|
||||||
|
microk8s=false
|
||||||
|
|
||||||
|
if [[ $(microk8s) ]]; then
|
||||||
|
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
|
||||||
|
if [ "$microk8s" = true ] ; then
|
||||||
|
bootstrapMicrok8s
|
||||||
|
else
|
||||||
bootstrap
|
bootstrap
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $2 = "-wait" ]]; then
|
if [[ $2 = "-wait" ]]; then
|
||||||
|
if [ "$microk8s" = true ] ; then
|
||||||
|
waitUntilReadyMicrok8s
|
||||||
|
else
|
||||||
waitUntilReady
|
waitUntilReady
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# reset: uninstall, delete data, then bootstrap
|
# reset: uninstall, delete data, then bootstrap
|
||||||
if [[ $1 = "reset" ]]; then
|
if [[ $1 = "reset" ]]; then
|
||||||
|
if [ "$microk8s" = true ] ; then
|
||||||
|
resetMicrok8s
|
||||||
|
bootstrapMicrok8s
|
||||||
|
else
|
||||||
reset
|
reset
|
||||||
bootstrap
|
bootstrap
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $2 = "-wait" ]]; then
|
if [[ $2 = "-wait" ]]; then
|
||||||
|
if [ "$microk8s" = true ] ; then
|
||||||
|
waitUntilReadyMicrok8s
|
||||||
|
else
|
||||||
waitUntilReady
|
waitUntilReady
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# test: run backend tests
|
# test: run backend tests
|
||||||
if [[ $1 = "test" ]]; then
|
if [[ $1 = "test" ]]; then
|
||||||
run_tests
|
runTests
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# nightly: run nightly backend tests
|
# nightly: run nightly backend tests
|
||||||
if [[ $1 = "nightly" ]]; then
|
if [[ $1 = "nightly" ]]; then
|
||||||
run_nightly_tests
|
runNightlyTests
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Done"
|
echo "Done"
|
||||||
|
Loading…
Reference in New Issue
Block a user