|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# usage: install-blockstor.sh WORK_DIR |
| 4 | +# |
| 5 | +# Wires the blockstor controller + satellite onto a freshly-created |
| 6 | +# Talos+QEMU cluster (`make up NAME=<n>`). Idempotent: re-running on a |
| 7 | +# cluster that already has blockstor returns 0 with the rolling-update |
| 8 | +# bringing the latest images. |
| 9 | +# |
| 10 | +# Steps: |
| 11 | +# 1. apply CRDs from config/crd/bases/ |
| 12 | +# 2. apply blockstor-deploy.yaml (controller + RBAC + namespace) |
| 13 | +# 3. apply blockstor-satellite-daemonset.yaml |
| 14 | +# 4. wait for controller + satellites Running |
| 15 | +# |
| 16 | +# Assumes the host registry on 10.164.0.1:5000 is reachable from the |
| 17 | +# cluster (Talos config-patch trusts http for that mirror — see |
| 18 | +# stand/up.sh). |
| 19 | + |
| 20 | +set -euo pipefail |
| 21 | + |
| 22 | +WORK_DIR=${1:?work_dir required} |
| 23 | +export KUBECONFIG="$WORK_DIR/kubeconfig" |
| 24 | + |
| 25 | +REPO_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) |
| 26 | + |
| 27 | +echo ">> apply CRDs" |
| 28 | +kubectl apply -f "$REPO_ROOT/config/crd/bases/" 2>&1 | tail -5 |
| 29 | + |
| 30 | +echo ">> apply controller + RBAC" |
| 31 | +kubectl apply -f "$REPO_ROOT/stand/blockstor-deploy.yaml" 2>&1 | tail -5 |
| 32 | + |
| 33 | +echo ">> apply satellite DaemonSet" |
| 34 | +kubectl apply -f "$REPO_ROOT/stand/blockstor-satellite-daemonset.yaml" 2>&1 | tail -5 |
| 35 | + |
| 36 | +echo ">> wait for controller Running" |
| 37 | +kubectl -n blockstor-system rollout status deploy/blockstor-controller --timeout=120s |
| 38 | + |
| 39 | +echo ">> wait for satellites (3 workers)" |
| 40 | +deadline=$(( $(date +%s) + 180 )) |
| 41 | +while (( $(date +%s) < deadline )); do |
| 42 | + ready=$(kubectl -n blockstor-system get pods -l app=blockstor-satellite --no-headers 2>/dev/null \ |
| 43 | + | awk '{print $2}' | grep -c '^1/1$' || true) |
| 44 | + if [[ "$ready" == "3" ]]; then |
| 45 | + break |
| 46 | + fi |
| 47 | + sleep 5 |
| 48 | +done |
| 49 | + |
| 50 | +if [[ "$ready" != "3" ]]; then |
| 51 | + echo "FAIL: only $ready/3 satellites Running" |
| 52 | + kubectl -n blockstor-system get pods -l app=blockstor-satellite |
| 53 | + exit 1 |
| 54 | +fi |
| 55 | + |
| 56 | +echo ">> blockstor stack ready on $(basename "$WORK_DIR")" |
0 commit comments