who_need_help/scripts/kind-up.sh

46 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
set -eu
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
"$ROOT/scripts/bootstrap-kubernetes-tools.sh"
PATH="$ROOT/.tools/bin:$PATH"
export PATH
CLUSTER=who-need-help
MARKER="$ROOT/.tools/${CLUSTER}.owned"
if kind get clusters | grep -Fxq "$CLUSTER"; then
if [ ! -f "$MARKER" ]; then
echo "A kind cluster named '$CLUSTER' already exists but was not created by this project." >&2
echo "Refusing to modify it. Rename/remove it yourself or inspect it first." >&2
exit 1
fi
else
kind create cluster --config "$ROOT/deploy/kind/cluster.yaml"
touch "$MARKER"
fi
docker build --tag who-need-help:local "$ROOT"
kind load docker-image who-need-help:local --name "$CLUSTER"
kubectl create namespace who-need-help --dry-run=client --output=yaml | kubectl apply -f -
kubectl --namespace who-need-help apply -f "$ROOT/deploy/kind/dependencies.yaml"
kubectl --namespace who-need-help rollout status deployment/postgis
kubectl --namespace who-need-help rollout status deployment/mailpit
helm upgrade --install who-need-help "$ROOT/deploy/helm/who-need-help" \
--namespace who-need-help \
--values "$ROOT/deploy/helm/who-need-help/values-kind.yaml" \
--set-string app.codexSessionId="${CODEX_SESSION_ID:-${CODEX_THREAD_ID:-not-configured}}" \
--wait
kubectl --namespace who-need-help rollout restart \
deployment/who-need-help-who-need-help-web \
deployment/who-need-help-who-need-help-worker
kubectl --namespace who-need-help rollout status deployment/who-need-help-who-need-help-web
kubectl --namespace who-need-help rollout status deployment/who-need-help-who-need-help-worker
"$ROOT/scripts/verify-realtime-cluster.sh" kind
echo "Who Need Help: http://localhost:4011"
echo "Mailpit: http://localhost:8028"