|
| 1 | +#!/usr/bin/env bash |
| 2 | +# =============================================== |
| 3 | +# One-click install for production |
| 4 | +# =============================================== |
| 5 | +# Required env vars: |
| 6 | +# IMAGE_REGISTRY - container registry (e.g. ghcr.io/processcrash) |
| 7 | +# IMAGE_TAG - image tag to deploy (e.g. 1.0.0) |
| 8 | +# DB_PASSWORD - master database password |
| 9 | +# NACOS_PASSWORD - Nacos admin password |
| 10 | +# REDIS_PASSWORD - Redis password |
| 11 | +# Optional: |
| 12 | +# STORAGE_CLASS - Kubernetes storage class (default: gp3) |
| 13 | +# INGRESS_HOST - public hostname for ingress |
| 14 | +# TLS_SECRET_NAME - TLS secret name in the cluster |
| 15 | + |
| 16 | +set -euo pipefail |
| 17 | + |
| 18 | +: "${IMAGE_REGISTRY:?must be set}" |
| 19 | +: "${IMAGE_TAG:?must be set}" |
| 20 | +: "${DB_PASSWORD:?must be set}" |
| 21 | +: "${NACOS_PASSWORD:?must be set}" |
| 22 | +: "${REDIS_PASSWORD:?must be set}" |
| 23 | +STORAGE_CLASS="${STORAGE_CLASS:-gp3}" |
| 24 | +INGRESS_HOST="${INGRESS_HOST:-xarch.example.com}" |
| 25 | +TLS_SECRET_NAME="${TLS_SECRET_NAME:-xarch-tls}" |
| 26 | + |
| 27 | +HERE="$(cd "$(dirname "$0")" && pwd)" |
| 28 | +CHART_DIR="$(cd "$HERE/../xarch" && pwd)" |
| 29 | +VALUES_FILE="$CHART_DIR/../values-prod.yaml" |
| 30 | + |
| 31 | +# Pre-create TLS secret if not already there |
| 32 | +if ! kubectl get secret "$TLS_SECRET_NAME" >/dev/null 2>&1; then |
| 33 | + echo "WARN: TLS secret $TLS_SECRET_NAME does not exist; provision cert-manager first" >&2 |
| 34 | +fi |
| 35 | + |
| 36 | +echo "==> Installing xarch (prod profile) via Helm" |
| 37 | +helm upgrade --install xarch "$CHART_DIR" \ |
| 38 | + --namespace xarch --create-namespace \ |
| 39 | + --values "$VALUES_FILE" \ |
| 40 | + --set global.imageRegistry="$IMAGE_REGISTRY" \ |
| 41 | + --set global.imageTag="$IMAGE_TAG" \ |
| 42 | + --set mysql.auth.rootPassword="$DB_PASSWORD" \ |
| 43 | + --set nacos.auth.admin.password="$NACOS_PASSWORD" \ |
| 44 | + --set redis.auth.password="$REDIS_PASSWORD" \ |
| 45 | + --set ingress.hosts[0].host="$INGRESS_HOST" \ |
| 46 | + --set ingress.tls[0].secretName="$TLS_SECRET_NAME" \ |
| 47 | + --set persistence.storageClass="$STORAGE_CLASS" \ |
| 48 | + --atomic \ |
| 49 | + --wait --timeout 30m \ |
| 50 | + "$@" |
| 51 | + |
| 52 | +echo "" |
| 53 | +echo "==> Production install complete. Verify:" |
| 54 | +echo " kubectl -n xarch get pods" |
| 55 | +echo " kubectl -n xarch get ingress" |
| 56 | +echo " curl -k https://$INGRESS_HOST/actuator/health" |
0 commit comments