Skip to content

Commit d80d210

Browse files
author
usize
committed
Add an install script that enforces necessary ordering for a reliable install.
1 parent e5622d3 commit d80d210

File tree

3 files changed

+300
-45
lines changed

3 files changed

+300
-45
lines changed

deployment/examples/README.md

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,65 @@
22

33
Complete deployment examples for different Models-as-a-Service scenarios.
44

5-
## Prerequisites
5+
## Automated Installation (Recommended)
66

7-
Deploy [core-infrastructure](../core-infrastructure/) first:
7+
Use the install script to ensure proper installation sequence:
88

99
```bash
10-
# 1. Install Istio
11-
./scripts/installers/install-istio.sh
12-
13-
# 2. Install Cert Manager
14-
./scripts/installers/install-cert-manager.sh
15-
16-
# 3. Install KServe
17-
./scripts/installers/install-kserve.sh
18-
19-
# 4. Install Prometheus
20-
./scripts/installers/install-prometheus.sh
21-
22-
# Deploy core infrastructure
23-
export CLUSTER_DOMAIN="apps.your-cluster.com"
24-
export CLUSTER_DOMAIN="apps.your-cluster.com"
25-
cd ../core-infrastructure # from deployment/examples/
26-
kustomize build . | envsubst | kubectl apply -f -
27-
28-
## Platform-Specific Deployments
29-
30-
For platform-specific deployments with external access, use the overlays:
31-
32-
- **OpenShift**: `kustomize build ../overlays/openshift`
33-
- **Kubernetes**: `kustomize build ../overlays/kubernetes`
34-
- **Internal only**: Use the examples directly without overlays
35-
36-
See [overlays/README.md](../overlays/README.md) for more details.
10+
# Show available deployment types and options
11+
./scripts/install.sh --help
12+
13+
# Deploy with default settings (simulator deployment)
14+
./scripts/install.sh
15+
16+
# Deploy specific deployment type
17+
./scripts/install.sh gpu
18+
./scripts/install.sh basic
19+
20+
## Installation Sequence
21+
22+
The install script enforces this critical sequence for reliable deployment:
23+
24+
1. **Install Dependencies** - Install all required operators and tools
25+
```bash
26+
scripts/install-dependencies.sh --all
27+
```
28+
29+
2. **Set Cluster Domain** - Configure domain for external access
30+
```bash
31+
# For OpenShift clusters (auto-detected by install script)
32+
export CLUSTER_DOMAIN=$(kubectl get ingresses.config.openshift.io cluster -o jsonpath='{.spec.domain}')
33+
34+
# For non-OpenShift clusters, set manually
35+
export CLUSTER_DOMAIN="your-kubernetes-domain.com"
36+
```
37+
38+
3. **Clean Conflicting Operators** - Remove any conflicting Istio installations
39+
```bash
40+
kubectl -n gateway-system delete subscription sailoperator --ignore-not-found
41+
kubectl -n gateway-system delete csv sailoperator.v0.1.0 --ignore-not-found
42+
kubectl -n gateway-system delete deployment sail-operator --ignore-not-found
43+
kubectl -n gateway-system delete deployment istiod --ignore-not-found
44+
```
45+
46+
4. **Deploy Kuadrant Operators** - Install core infrastructure operators
47+
```bash
48+
kustomize build core-infrastructure/kustomize-templates/kuadrant | envsubst | kubectl apply -f -
49+
```
50+
51+
5. **Wait for Operators** - Ensure all operators are ready before proceeding
52+
```bash
53+
kubectl wait --for=condition=available deployment/kuadrant-operator-controller-manager -n kuadrant-system --timeout=300s
54+
kubectl wait --for=condition=available deployment/limitador-operator-controller-manager -n kuadrant-system --timeout=300s
55+
kubectl wait --for=condition=available deployment/authorino-operator -n kuadrant-system --timeout=300s
56+
```
57+
58+
6. **Deploy with External Access** - Deploy the selected example with OpenShift overlay
59+
```bash
60+
kustomize build overlays/openshift | envsubst | kubectl apply -f -
61+
```
62+
63+
**Important**: This sequence prevents common issues like operator conflicts and ensures dependencies are ready before deployment.
3764

3865
## Available Examples
3966

deployment/scripts/install.sh

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Script to install MaaS deployment with configurable options
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
DEPLOYMENT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
8+
9+
# Default values
10+
DEPLOYMENTcurl -sk -X GET https://key-manager-route-platform-services.apps.summit-gpu.octo-emerging.redhataicoe.com/teams \
11+
-H "Authorization: ADMIN $ADMIN_KEY" | jq ._TYPE="simulator"
12+
TEARDOWN=false
13+
AVAILABLE_DEPLOYMENTS=()
14+
15+
# Colors for output
16+
RED='\033[0;31m'
17+
GREEN='\033[0;32m'
18+
YELLOW='\033[1;33m'
19+
NC='\033[0m' # No Color
20+
21+
log_info() {
22+
echo -e "${YELLOW}[INFO]${NC} $1"
23+
}
24+
25+
log_success() {
26+
echo -e "${GREEN}[SUCCESS]${NC} $1"
27+
}
28+
29+
log_error() {
30+
echo -e "${RED}[ERROR]${NC} $1"
31+
}
32+
33+
show_usage() {
34+
echo "Usage: $0 [--teardown] [deployment-type]"
35+
echo
36+
echo "Install MaaS deployment with optional teardown and configurable deployment type."
37+
echo
38+
echo "Options:"
39+
echo " --teardown Run teardown before installation (optional)"
40+
echo " --help Show this help message"
41+
echo
42+
echo "Deployment Types:"
43+
for deployment in "${AVAILABLE_DEPLOYMENTS[@]}"; do
44+
echo " $deployment"
45+
done
46+
echo
47+
echo "Default: $DEPLOYMENT_TYPE"
48+
echo
49+
echo "Examples:"
50+
echo " $0 # Install simulator deployment (default)"
51+
echo " $0 gpu # Install gpu deployment"
52+
echo " $0 --teardown basic # Teardown first, then install basic deployment"
53+
echo " $0 --teardown # Teardown first, then install simulator deployment"
54+
}
55+
56+
detect_available_deployments() {
57+
# Only detect if not already done
58+
if [ ${#AVAILABLE_DEPLOYMENTS[@]} -eq 0 ]; then
59+
log_info "Detecting available deployments..."
60+
61+
if [ ! -d "$DEPLOYMENT_DIR/examples" ]; then
62+
log_error "Examples directory not found: $DEPLOYMENT_DIR/examples"
63+
exit 1
64+
fi
65+
66+
for dir in "$DEPLOYMENT_DIR/examples"/*; do
67+
if [ -d "$dir" ] && [ -f "$dir/kustomization.yaml" ]; then
68+
deployment_name=$(basename "$dir")
69+
# Remove "-deployment" suffix if present for cleaner names
70+
deployment_name=${deployment_name%-deployment}
71+
AVAILABLE_DEPLOYMENTS+=("$deployment_name")
72+
fi
73+
done
74+
75+
if [ ${#AVAILABLE_DEPLOYMENTS[@]} -eq 0 ]; then
76+
log_error "No valid deployments found in examples directory"
77+
exit 1
78+
fi
79+
80+
log_info "Found deployments: ${AVAILABLE_DEPLOYMENTS[*]}"
81+
fi
82+
}
83+
84+
validate_deployment() {
85+
local deployment="$1"
86+
87+
# Add "-deployment" suffix if not present
88+
local deployment_dir="$DEPLOYMENT_DIR/examples/${deployment}-deployment"
89+
if [ ! -d "$deployment_dir" ]; then
90+
deployment_dir="$DEPLOYMENT_DIR/examples/${deployment}"
91+
fi
92+
93+
if [ ! -d "$deployment_dir" ] || [ ! -f "$deployment_dir/kustomization.yaml" ]; then
94+
log_error "Invalid deployment type: $deployment"
95+
log_error "Available deployments: ${AVAILABLE_DEPLOYMENTS[*]}"
96+
exit 1
97+
fi
98+
99+
echo "$deployment_dir"
100+
}
101+
102+
set_cluster_domain() {
103+
# Set default CLUSTER_DOMAIN if not already set
104+
if [ -z "${CLUSTER_DOMAIN:-}" ]; then
105+
if kubectl get ingresses.config.openshift.io cluster &>/dev/null; then
106+
# OpenShift cluster - get domain from ingress config
107+
export CLUSTER_DOMAIN=$(kubectl get ingresses.config.openshift.io cluster -o jsonpath='{.spec.domain}')
108+
else
109+
# Fallback for non-OpenShift clusters
110+
export CLUSTER_DOMAIN="cluster.local"
111+
fi
112+
log_info "Detected CLUSTER_DOMAIN: $CLUSTER_DOMAIN"
113+
else
114+
log_info "Using existing CLUSTER_DOMAIN: $CLUSTER_DOMAIN"
115+
fi
116+
}
117+
118+
parse_arguments() {
119+
while [[ $# -gt 0 ]]; do
120+
case $1 in
121+
--teardown)
122+
TEARDOWN=true
123+
shift
124+
;;
125+
--help)
126+
detect_available_deployments
127+
show_usage
128+
exit 0
129+
;;
130+
--*)
131+
log_error "Unknown option: $1"
132+
show_usage
133+
exit 1
134+
;;
135+
*)
136+
DEPLOYMENT_TYPE="$1"
137+
shift
138+
;;
139+
esac
140+
done
141+
}
142+
143+
main() {
144+
# Detect available deployments first
145+
detect_available_deployments
146+
147+
# Show help if no arguments provided
148+
if [ $# -eq 0 ]; then
149+
show_usage
150+
exit 0
151+
fi
152+
153+
log_info "Starting MaaS deployment installation"
154+
155+
# Parse command line arguments
156+
parse_arguments "$@"
157+
158+
# Validate deployment type
159+
DEPLOYMENT_PATH=$(validate_deployment "$DEPLOYMENT_TYPE")
160+
log_info "Using deployment: $DEPLOYMENT_TYPE ($(basename "$DEPLOYMENT_PATH"))"
161+
162+
# Set cluster domain
163+
set_cluster_domain
164+
165+
# Change to deployment directory
166+
cd "$DEPLOYMENT_DIR"
167+
168+
# Optional teardown
169+
if [ "$TEARDOWN" = true ]; then
170+
log_info "Running teardown..."
171+
if [ -f "scripts/teardown.sh" ]; then
172+
scripts/teardown.sh
173+
log_success "Teardown completed"
174+
else
175+
log_error "Teardown script not found: scripts/teardown.sh"
176+
exit 1
177+
fi
178+
fi
179+
180+
# Install dependencies
181+
log_info "Installing dependencies..."
182+
scripts/install-dependencies.sh --all
183+
log_success "Dependencies installed"
184+
185+
# Clean up any conflicting operators
186+
log_info "Cleaning up conflicting operators..."
187+
kubectl -n gateway-system delete subscription sailoperator --ignore-not-found
188+
kubectl -n gateway-system delete csv sailoperator.v0.1.0 --ignore-not-found
189+
kubectl -n gateway-system delete deployment sail-operator --ignore-not-found
190+
kubectl -n gateway-system delete deployment istiod --ignore-not-found
191+
192+
# Deploy Kuadrant operators first
193+
log_info "Deploying Kuadrant operators..."
194+
kustomize build core-infrastructure/kustomize-templates/kuadrant | envsubst | kubectl apply -f -
195+
log_success "Kuadrant operators deployed"
196+
197+
# Wait for operators to be ready
198+
log_info "Waiting for operators to be ready..."
199+
kubectl wait --for=condition=available deployment/kuadrant-operator-controller-manager -n kuadrant-system --timeout=300s && \
200+
kubectl wait --for=condition=available deployment/limitador-operator-controller-manager -n kuadrant-system --timeout=300s && \
201+
kubectl wait --for=condition=available deployment/authorino-operator -n kuadrant-system --timeout=300s
202+
log_success "All operators are ready"
203+
204+
# Deploy using overlay (always use OpenShift overlay for external access)
205+
log_info "Deploying $DEPLOYMENT_TYPE with external access..."
206+
kustomize build overlays/openshift | envsubst | kubectl apply -f -
207+
log_success "Deployment completed successfully!"
208+
209+
# Show access information
210+
echo
211+
log_success "=== Deployment Complete ==="
212+
log_info "Cluster Domain: $CLUSTER_DOMAIN"
213+
log_info "External Routes:"
214+
echo " - Simulator: simulator-llm.$CLUSTER_DOMAIN"
215+
echo " - Qwen3: qwen3-llm.$CLUSTER_DOMAIN"
216+
echo " - Key Manager: key-manager.$CLUSTER_DOMAIN"
217+
echo
218+
log_info "Check deployment status with:"
219+
echo " kubectl get pods -n llm"
220+
echo " kubectl get routes -n llm"
221+
}
222+
223+
main "$@"

0 commit comments

Comments
 (0)