All checks were successful
Run Check Script / check (pull_request) Successful in 2m17s
77 lines
3.0 KiB
Bash
Executable File
77 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build + push + deploy the fleet operator to staging in one shot — the
|
|
# fast inner loop that skips the git-tag → CI → release ceremony.
|
|
#
|
|
# It runs the SAME two binaries the release/CD path uses, just with a
|
|
# throwaway dev version:
|
|
# 1. harmony-fleet-publish — docker-build the operator image (with the
|
|
# web dashboard), generate the helm chart, push BOTH to the OCI
|
|
# registry.
|
|
# 2. harmony-fleet-deploy — helm upgrade --install that chart onto
|
|
# staging, applying the dashboard ingress + Service + cert-manager
|
|
# cert (host/issuer come from FleetDeployConfig).
|
|
#
|
|
# Each run gets a unique semver-dev version, so the node always pulls a
|
|
# fresh image and helm rolls a new ReplicaSet — no `:dev`-tag cache traps.
|
|
# The first build is a full compile; thereafter the Dockerfile's BuildKit
|
|
# cache mounts recompile only what changed (seconds).
|
|
#
|
|
# Usage:
|
|
# ./fleet/scripts/dev-deploy-operator.sh
|
|
# REGISTRY=hub.nationtech.io PROJECT=harmony ./fleet/scripts/dev-deploy-operator.sh
|
|
# PUBLISH_ONLY=1 ./fleet/scripts/dev-deploy-operator.sh # build+push, skip deploy
|
|
#
|
|
# Prerequisites (same as the release path):
|
|
# - docker (BuildKit) + helm on PATH, logged in to $REGISTRY.
|
|
# - The deploy reads FleetDeployConfig + FleetDeploySecrets for
|
|
# $CONFIG_NAMESPACE (Env → OpenBao). Provide them however you already
|
|
# do for `harmony-fleet-deploy` — e.g. a sourced `.envrc` with
|
|
# OPENBAO_URL / OPENBAO_TOKEN / HARMONY_CONFIG_NAMESPACE, and a
|
|
# KUBECONFIG pointed at staging (or a kubeconfig seeded in OpenBao).
|
|
|
|
set -euo pipefail
|
|
|
|
REGISTRY="${REGISTRY:-hub.nationtech.io}"
|
|
PROJECT="${PROJECT:-harmony}"
|
|
CONFIG_NAMESPACE="${CONFIG_NAMESPACE:-fleet-staging}"
|
|
PUBLISH_ONLY="${PUBLISH_ONLY:-0}"
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
cd "$REPO_ROOT"
|
|
|
|
# Pick up a local .envrc (OpenBao creds, KUBECONFIG, …) if present and
|
|
# not already loaded by direnv.
|
|
if [[ -f "$REPO_ROOT/.envrc" ]]; then
|
|
# shellcheck disable=SC1091
|
|
source "$REPO_ROOT/.envrc"
|
|
fi
|
|
|
|
# Unique + semver-valid: helm rejects a non-semver chart version, and a
|
|
# fresh version forces a clean image pull + rollout every iteration.
|
|
VERSION="0.0.0-dev.$(date -u +'%Y%m%d%H%M%S')"
|
|
|
|
export DOCKER_BUILDKIT=1
|
|
|
|
echo "==> [1/2] build + push image and chart @ ${VERSION}"
|
|
cargo run -q -p harmony-fleet-deploy --bin harmony-fleet-publish -- \
|
|
--version "$VERSION" \
|
|
--registry "$REGISTRY" \
|
|
--project "$PROJECT"
|
|
|
|
if [[ "$PUBLISH_ONLY" == "1" ]]; then
|
|
echo "==> PUBLISH_ONLY=1, skipping deploy. Chart: oci://${REGISTRY}/${PROJECT}/harmony-fleet-operator-chart:${VERSION}"
|
|
exit 0
|
|
fi
|
|
|
|
echo "==> [2/2] deploy chart @ ${VERSION} to ${CONFIG_NAMESPACE}"
|
|
cargo run -q -p harmony-fleet-deploy --bin harmony-fleet-deploy -- \
|
|
--operator-chart-version "$VERSION" \
|
|
--operator-chart-registry "$REGISTRY" \
|
|
--operator-chart-project "$PROJECT" \
|
|
--config-namespace "$CONFIG_NAMESPACE" \
|
|
--yes
|
|
|
|
echo
|
|
echo "Deployed ${REGISTRY}/${PROJECT}/harmony-fleet-operator:${VERSION} to ${CONFIG_NAMESPACE}."
|