|
60 | 60 | # # Test custom MaaS API image |
61 | 61 | # MAAS_API_IMAGE=quay.io/myuser/maas-api:pr-123 ./scripts/deploy.sh |
62 | 62 | # |
| 63 | +# # Use external PostgreSQL (production) |
| 64 | +# ./scripts/deploy.sh --postgres-connection 'postgresql://user:pass@db.example.com:5432/maas?sslmode=require' |
| 65 | +# |
63 | 66 | # For detailed documentation, see: |
64 | 67 | # https://opendatahub-io.github.io/models-as-a-service/latest/install/maas-setup/ |
65 | 68 | ################################################################################ |
@@ -108,6 +111,7 @@ MAAS_API_IMAGE="${MAAS_API_IMAGE:-}" |
108 | 111 | MAAS_CONTROLLER_IMAGE="${MAAS_CONTROLLER_IMAGE:-}" |
109 | 112 | KUSTOMIZE_FORCE_CONFLICTS="${KUSTOMIZE_FORCE_CONFLICTS:-false}" |
110 | 113 | EXTERNAL_OIDC="${EXTERNAL_OIDC:-false}" |
| 114 | +POSTGRES_CONNECTION="${POSTGRES_CONNECTION:-}" |
111 | 115 |
|
112 | 116 | #────────────────────────────────────────────────────────────── |
113 | 117 | # HELP TEXT |
@@ -144,6 +148,11 @@ OPTIONS: |
144 | 148 | Creates keycloak-system namespace and deploys Keycloak operator |
145 | 149 | See docs/samples/install/keycloak/ for configuration guide |
146 | 150 |
|
| 151 | + --postgres-connection <connection-string> |
| 152 | + Use an external PostgreSQL database instead of deploying a POC instance. |
| 153 | + Format: postgresql://USER:PASSWORD@HOST:PORT/DATABASE?sslmode=require |
| 154 | + When set, skips the built-in PostgreSQL deployment entirely. |
| 155 | +
|
147 | 156 | --namespace <namespace> |
148 | 157 | Target namespace for deployment |
149 | 158 | Default: redhat-ods-applications (RHOAI) or opendatahub (ODH) |
@@ -195,6 +204,7 @@ ENVIRONMENT VARIABLES: |
195 | 204 | OIDC_ISSUER_URL External OIDC issuer URL for maas-api AuthPolicy patching |
196 | 205 | LOG_LEVEL Logging verbosity (DEBUG, INFO, WARN, ERROR) |
197 | 206 | KUSTOMIZE_FORCE_CONFLICTS When true, pass --force-conflicts to kubectl apply in kustomize mode (default: false) |
| 207 | + POSTGRES_CONNECTION External PostgreSQL connection string (same as --postgres-connection) |
198 | 208 |
|
199 | 209 | TIMEOUT CONFIGURATION (all values in seconds): |
200 | 210 | Customize timeouts for slow clusters or CI/CD environments: |
@@ -229,6 +239,9 @@ EXAMPLES: |
229 | 239 | --operator-catalog quay.io/opendatahub/opendatahub-operator-catalog:pr-456 \\ |
230 | 240 | --operator-image quay.io/opendatahub/opendatahub-operator:pr-456 |
231 | 241 |
|
| 242 | + # Use an external PostgreSQL database |
| 243 | + ./scripts/deploy.sh --postgres-connection 'postgresql://user:pass@rds.example.com:5432/maas?sslmode=require' |
| 244 | +
|
232 | 245 | For more information, see: https://github.com/opendatahub-io/models-as-a-service |
233 | 246 | EOF |
234 | 247 | } |
@@ -314,6 +327,11 @@ parse_arguments() { |
314 | 327 | OPERATOR_CHANNEL="$2" |
315 | 328 | shift 2 |
316 | 329 | ;; |
| 330 | + --postgres-connection) |
| 331 | + require_flag_value "$1" "${2:-}" |
| 332 | + POSTGRES_CONNECTION="$2" |
| 333 | + shift 2 |
| 334 | + ;; |
317 | 335 | --external-oidc) |
318 | 336 | EXTERNAL_OIDC="true" |
319 | 337 | shift |
@@ -697,8 +715,30 @@ deploy_via_kustomize() { |
697 | 715 | # POSTGRESQL DEPLOYMENT |
698 | 716 | #────────────────────────────────────────────────────────────── |
699 | 717 |
|
| 718 | +validate_postgres_connection() { |
| 719 | + local conn="$1" |
| 720 | + if [[ ! "$conn" =~ ^postgres(ql)?:// ]]; then |
| 721 | + log_error "Invalid PostgreSQL connection string format" |
| 722 | + log_error "Expected: postgresql://USER:PASSWORD@HOST:PORT/DATABASE?sslmode=require" |
| 723 | + return 1 |
| 724 | + fi |
| 725 | +} |
| 726 | + |
700 | 727 | deploy_postgresql() { |
701 | | - NAMESPACE="$NAMESPACE" "${SCRIPT_DIR}/setup-database.sh" |
| 728 | + if [[ -n "$POSTGRES_CONNECTION" ]]; then |
| 729 | + validate_postgres_connection "$POSTGRES_CONNECTION" || exit 1 |
| 730 | + log_info "Using external PostgreSQL connection" |
| 731 | + create_maas_db_config_secret "$NAMESPACE" "$POSTGRES_CONNECTION" |
| 732 | + log_info "Created maas-db-config secret with external connection" |
| 733 | + else |
| 734 | + log_warn "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 735 | + log_warn " DEPLOYING POC POSTGRESQL — NOT INTENDED FOR PRODUCTION USE" |
| 736 | + log_warn " Data is stored in ephemeral storage and will be lost on pod restart." |
| 737 | + log_warn " For production, use --postgres-connection with an external database" |
| 738 | + log_warn " (AWS RDS, Crunchy Operator, Azure Database, etc.)" |
| 739 | + log_warn "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 740 | + NAMESPACE="$NAMESPACE" "${SCRIPT_DIR}/setup-database.sh" |
| 741 | + fi |
702 | 742 | } |
703 | 743 |
|
704 | 744 | #────────────────────────────────────────────────────────────── |
|
0 commit comments