-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·920 lines (776 loc) · 29.5 KB
/
install.sh
File metadata and controls
executable file
·920 lines (776 loc) · 29.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
#!/usr/bin/env bash
#############################################################################
# AIOStack Interactive Installer By Aurva Inc
#
# A production-ready interactive installation script for AIOStack Kubernetes
# application that guides users through the complete installation process.
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/aurva-io/AIOstack/main/install.sh | bash
#
# OR download and run locally:
#
# ./install.sh # Interactive mode
# ./install.sh --config config.yaml # Load saved config
# ./install.sh --help # Show help
# ./install.sh -v # Verbose mode
#
# Requirements:
# - Helm 3.x
# - kubectl configured with cluster access
# - Kubernetes 1.29+ with eBPF support
# - Linux kernel 5.15+
#
# Author: Aurva (https://aurva.io)
# License: Apache 2.0
#############################################################################
set -euo pipefail
# Script version
VERSION="1.0.3"
# Configuration file path
CONFIG_FILE="${CONFIG_FILE:-}"
VERBOSE="${VERBOSE:-false}"
# Color codes for output (Green, White, Red theme)
RED='\033[0;31m'
GREEN='\033[0;32m'
BRIGHT_GREEN='\033[1;32m'
WHITE='\033[0;37m'
BOLD='\033[1m'
NC='\033[0m' # No Color
# Configuration variables
COMPANY_ID=""
VALIDATION_KEY=""
NAMESPACE="aiostack"
RELEASE_NAME="myaiostack"
IS_OUTPOST_URL_SECURE="false"
SKIP_NAMESPACES="kube-system,aiostack-test,myaiostack,aiostack,monitoring,gke-mcs"
COMMANDER_URL="hq.aurva.ai:443"
INSECURE_SKIP_VERIFY="true"
OBSERVER_VERSION="latest"
OUTPOST_VERSION="latest"
CREATE_NAMESPACE="true"
HELM_REPO_NAME="aiostack"
HELM_REPO_URL="https://charts.aurva.ai/"
HELM_CHART="${HELM_REPO_NAME}/aiostack"
# State tracking
CURRENT_STEP=0
TOTAL_STEPS=7
HELM_REPO_ADDED=false
NAMESPACE_CREATED=false
INSTALLATION_STARTED=false
#############################################################################
# Helper Functions
#############################################################################
# Print colored output
print_color() {
local color=$1
shift
echo -e "${color}$*${NC}"
}
# Print step header
print_step() {
CURRENT_STEP=$((CURRENT_STEP + 1))
local label="Step ${CURRENT_STEP}/${TOTAL_STEPS}: $1"
local width=79 # total inner width (between │ chars)
local pad=$(( width - ${#label} - 1 )) # -2 for "| " prefix space and " " before "|"
printf "\n"
print_color "$BOLD$BRIGHT_GREEN" "╭$(printf '─%.0s' $(seq 1 $width))╮"
print_color "$BOLD$BRIGHT_GREEN" "| ${label}$(printf ' %.0s' $(seq 1 $pad))|"
print_color "$BOLD$BRIGHT_GREEN" "╰$(printf '─%.0s' $(seq 1 $width))╯"
printf "\n"
}
# Print success message
print_success() {
print_color "$GREEN" "✓ $*"
}
# Print error message
print_error() {
print_color "$RED" "✗ $*"
}
# Print warning message
print_warning() {
print_color "$BRIGHT_GREEN" "⚠ $*"
}
# Print info message
print_info() {
print_color "$WHITE" "ℹ $*"
}
# Print verbose message (only if verbose mode is enabled)
print_verbose() {
if [[ "$VERBOSE" == "true" ]]; then
print_color "$WHITE" "[VERBOSE] $*"
fi
}
# Show loading animation
show_loading() {
local pid=$1
local message=$2
local spin='-\|/'
local i=0
while kill -0 "$pid" 2>/dev/null; do
i=$(( (i+1) %4 ))
printf "\r${GREEN}${message} ${spin:$i:1}${NC}"
sleep 0.1
done
printf "\r"
}
# Prompt user with default value
prompt() {
local prompt_message=$1
local default_value=$2
local user_input
if [[ -n "$default_value" ]]; then
read -r -p "$(echo -e "${BRIGHT_GREEN}${prompt_message} [${default_value}]:${NC} ")" user_input < /dev/tty
echo "${user_input:-$default_value}"
else
read -r -p "$(echo -e "${BRIGHT_GREEN}${prompt_message}:${NC} ")" user_input < /dev/tty
echo "$user_input"
fi
}
# Prompt for sensitive input (masked)
prompt_secure() {
local prompt_message=$1
local user_input
read -r -s -p "$(echo -e "${BRIGHT_GREEN}${prompt_message}:${NC} ")" user_input < /dev/tty
echo "" # New line after hidden input
echo "$user_input"
}
# Ask yes/no question
ask_yes_no() {
local prompt_message=$1
local default_value=${2:-"y"}
local response
if [[ "$default_value" == "y" ]]; then
read -r -p "$(echo -e "${BRIGHT_GREEN}${prompt_message} [Y/n]:${NC} ")" response < /dev/tty
response=${response:-y}
else
read -r -p "$(echo -e "${BRIGHT_GREEN}${prompt_message} [y/N]:${NC} ")" response < /dev/tty
response=${response:-n}
fi
[[ "$response" =~ ^[Yy]$ ]]
}
# Open URL in default browser (cross-platform)
open_browser() {
local url=$1
print_verbose "Attempting to open URL: ${url}"
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
open "$url" &>/dev/null || print_warning "Could not open browser automatically"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux
if command -v xdg-open &> /dev/null; then
xdg-open "$url" &>/dev/null || print_warning "Could not open browser automatically"
elif command -v gnome-open &> /dev/null; then
gnome-open "$url" &>/dev/null || print_warning "Could not open browser automatically"
else
print_warning "Could not detect browser opener"
fi
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
# Windows
start "$url" &>/dev/null || print_warning "Could not open browser automatically"
else
print_verbose "Unknown OS type: ${OSTYPE}"
fi
}
# Print banner
print_banner() {
clear
print_color "$BOLD$BRIGHT_GREEN" "
╭──────────────────────────────────────────────────────╮
│ │
│ ▝▀▖▌ ▌▙▀▖▌ ▌▝▀▖ AIOStack ◎ Agentic Installer │
│ ▞▀▌▌ ▌▌ ▐▐ ▞▀▌ v${VERSION} │
│ ▝▀▘▝▀▘▘ ▘ ▝▀▘ ◎ Runtime AI Security ◎ │
│ │
╰──────────────────────────────────────────────────────╯
"
print_info "Discover AI components you didn't know existed!"
print_info "Website: https://aurva.ai | Docs: https://aurva.ai/docs/home"
echo ""
}
# Show help
show_help() {
cat << EOF
AIOStack Interactive Installer v${VERSION}
EMAIL :
USAGE:
$0 [OPTIONS]
OPTIONS:
-h, --help Show this help message
-v, --verbose Enable verbose output
-c, --config FILE Load configuration from file
--version Show version information
EXAMPLES:
# Interactive installation (recommended)
$0
# Load saved configuration
$0 --config aiostack-config.yaml
# Verbose mode for debugging
$0 --verbose
# Quick install via curl
curl -fsSL https://aurva.ai/install.sh | bash
REQUIREMENTS:
- Helm 3.x installed
- kubectl configured with cluster access
- Kubernetes 1.29+ with eBPF support
- Linux kernel 5.15+ on cluster nodes
SUPPORT:
- Documentation: https://aurva.ai/docs/installation/steps
- Issues: https://github.com/aurva-io/ai-observability-stack/issues
- Email: [email protected]
EOF
exit 0
}
#############################################################################
# Core Functions
#############################################################################
# Check prerequisites
check_prerequisites() {
print_step "Checking Prerequisites"
local all_checks_passed=true
# Check Helm
print_info "Checking for Helm..."
if command -v helm &> /dev/null; then
local helm_version
helm_version=$(helm version --short 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1)
print_success "Helm is installed: ${helm_version}"
print_verbose "Helm path: $(which helm)"
else
print_error "Helm is not installed"
print_info "Install from: https://helm.sh/docs/intro/install/"
all_checks_passed=false
fi
# Check kubectl
print_info "Checking for kubectl..."
if command -v kubectl &> /dev/null; then
local kubectl_version
kubectl_version=$(kubectl version --client --short 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' || echo "unknown")
print_success "kubectl is installed: ${kubectl_version}"
print_verbose "kubectl path: $(which kubectl)"
else
print_error "kubectl is not installed"
print_info "Install from: https://kubernetes.io/docs/tasks/tools/"
all_checks_passed=false
fi
# Check cluster connectivity
if command -v kubectl &> /dev/null; then
print_info "Checking cluster connectivity..."
if kubectl cluster-info &> /dev/null; then
local context
context=$(kubectl config current-context 2>/dev/null || echo "unknown")
print_success "Connected to cluster: ${context}"
print_verbose "Cluster info: $(kubectl cluster-info | head -1)"
# Check Kubernetes version
local k8s_version
k8s_version=$(kubectl version --short 2>/dev/null | grep "Server Version" | grep -oE 'v[0-9]+\.[0-9]+' || echo "unknown")
print_info "Kubernetes version: ${k8s_version}"
# Warn if version is too old
if [[ "$k8s_version" != "unknown" ]]; then
local major minor
major=$(echo "$k8s_version" | cut -d'.' -f1 | tr -d 'v')
minor=$(echo "$k8s_version" | cut -d'.' -f2)
if [[ $major -eq 1 && $minor -lt 29 ]]; then
print_warning "Kubernetes 1.29+ is recommended. Your version: ${k8s_version}"
fi
fi
else
print_error "Cannot connect to Kubernetes cluster"
print_info "Configure kubectl with: kubectl config use-context <context-name>"
all_checks_passed=false
fi
fi
if [[ "$all_checks_passed" == "false" ]]; then
echo ""
print_error "Prerequisites check failed. Please install missing components and try again."
exit 1
fi
echo ""
print_success "All prerequisites are met!"
}
# Setup Helm repository
setup_helm_repo() {
print_step "Setting Up Helm Repository"
print_info "Adding Aurva Helm repository..."
print_verbose "Repo URL: ${HELM_REPO_URL}"
if helm repo add "$HELM_REPO_NAME" "$HELM_REPO_URL" &> /dev/null; then
print_success "Repository added successfully"
HELM_REPO_ADDED=true
else
# Repository might already exist, try to update
print_info "Repository already exists, updating..."
fi
print_info "Updating Helm repositories..."
if helm repo update &> /dev/null; then
print_success "Repositories updated successfully"
else
print_error "Failed to update repositories"
exit 1
fi
# Verify chart is available
print_info "Verifying chart availability..."
if helm search repo "${HELM_CHART}" &> /dev/null; then
local chart_version
chart_version=$(helm search repo "${HELM_CHART}" --output json 2>/dev/null | grep -oE '"version":"[^"]*"' | head -1 | cut -d'"' -f4 || echo "unknown")
print_success "Chart is available: ${HELM_CHART} (latest: ${chart_version})"
else
print_error "Chart not found: ${HELM_CHART}"
exit 1
fi
}
# Collect credentials
collect_credentials() {
print_step "Collecting Credentials"
echo ""
print_color "$BOLD$BRIGHT_GREEN" "Before proceeding, you need credentials from Aurva:"
echo ""
print_info "1. Sign up for a free account (takes 30 seconds)"
print_info "2. Check your registered email for your credentials:"
print_info " - Company ID"
print_info " - AIOStack Validation Key"
echo ""
# Ask if they want to open the signup page
if ask_yes_no "Open signup page in your browser? (return to the terminal once you get your signup code)" "y"; then
print_info "Opening https://app.aurva.ai/signup in your browser..."
open_browser "https://app.aurva.ai/signup"
sleep 2 # Give the browser time to open
echo ""
else
print_info "Please visit: https://app.aurva.ai/signup"
echo ""
fi
if ! ask_yes_no "Have you received your credentials via email?"; then
echo ""
print_error "Please complete signup at https://app.aurva.ai/signup"
print_info "Your credentials will be sent to your registered email address"
print_info "Once you receive them, run this script again"
exit 0
fi
echo ""
print_info "Please enter your credentials:"
echo ""
# Collect Company ID
while [[ -z "$COMPANY_ID" ]]; do
COMPANY_ID=$(prompt "Company ID" "")
# Trim leading and trailing whitespace
COMPANY_ID=$(echo "$COMPANY_ID" | xargs)
if [[ -z "$COMPANY_ID" ]]; then
print_error "Company ID cannot be empty"
elif [[ ! "$COMPANY_ID" =~ ^[a-zA-Z0-9_-]+$ ]]; then
print_warning "Company ID contains unusual characters. Continue anyway? (y/n)"
if ! ask_yes_no "Continue with this Company ID?" "n"; then
COMPANY_ID=""
fi
fi
done
# Collect Validation Key
while [[ -z "$VALIDATION_KEY" ]]; do
VALIDATION_KEY=$(prompt_secure "AIOStack Validation Key (input hidden)")
# Trim leading and trailing whitespace
VALIDATION_KEY=$(echo "$VALIDATION_KEY" | xargs)
if [[ -z "$VALIDATION_KEY" ]]; then
print_error "Validation Key cannot be empty"
fi
done
echo ""
print_success "Credentials collected successfully"
print_info "Whitespace automatically trimmed from inputs"
print_verbose "Company ID: ${COMPANY_ID}"
print_verbose "Validation Key: [HIDDEN]"
echo ""
print_info "Press Enter to continue to namespace configuration..."
read -r -p "" < /dev/tty
}
# Configure namespace
configure_namespace() {
print_step "Configuring Namespace"
echo ""
NAMESPACE=$(prompt "Enter namespace for AIOStack" "$NAMESPACE")
# Check if namespace exists
if kubectl get namespace "$NAMESPACE" &> /dev/null; then
print_info "Namespace '${NAMESPACE}' already exists"
# Check if there are existing AIOStack resources
local existing_pods
existing_pods=$(kubectl get pods -n "$NAMESPACE" -l "app.kubernetes.io/instance=${RELEASE_NAME}" 2>/dev/null | grep -c "^" || echo "0")
if [[ $existing_pods -gt 1 ]]; then
print_warning "Found existing AIOStack installation in this namespace"
if ask_yes_no "Do you want to use a different release name?" "y"; then
RELEASE_NAME=$(prompt "Enter release name" "myaiostack-$(date +%s)")
fi
fi
CREATE_NAMESPACE="false"
else
print_info "Namespace '${NAMESPACE}' does not exist"
if ask_yes_no "Create namespace '${NAMESPACE}'?" "y"; then
CREATE_NAMESPACE="true"
print_success "Will create namespace during installation"
else
print_error "Cannot proceed without a namespace"
exit 1
fi
fi
print_verbose "Namespace: ${NAMESPACE}"
print_verbose "Create namespace: ${CREATE_NAMESPACE}"
}
# Collect environment configuration
collect_env_config() {
print_step "Configuring Environment Settings"
echo ""
print_info "Configuring optional settings (press Enter to use defaults)..."
echo ""
# Release name
RELEASE_NAME=$(prompt "Helm release name" "$RELEASE_NAME")
# Skip namespaces
echo ""
print_info "Configure which namespaces to skip during monitoring:"
print_info " Current: ${SKIP_NAMESPACES}"
if ask_yes_no "Customize skipped namespaces?" "n"; then
SKIP_NAMESPACES=$(prompt "Enter comma-separated namespaces to skip" "$SKIP_NAMESPACES")
fi
echo ""
print_success "Configuration completed"
}
# Review configuration
review_config() {
print_step "Reviewing Configuration"
echo ""
print_color "$BOLD$BRIGHT_GREEN" "Please review your configuration:"
echo ""
print_color "$BOLD" "Credentials:"
echo " Company ID: ${COMPANY_ID}"
echo " Validation Key: [HIDDEN - ${#VALIDATION_KEY} characters]"
echo ""
print_color "$BOLD" "Installation:"
echo " Namespace: ${NAMESPACE}"
echo " Release Name: ${RELEASE_NAME}"
echo " Chart: ${HELM_CHART}"
echo ""
print_color "$BOLD" "Component Versions:"
echo " Observer: ${OBSERVER_VERSION}"
echo " Outpost: ${OUTPOST_VERSION}"
echo ""
print_color "$BOLD" "Configuration:"
echo " Outpost URL Secure: ${IS_OUTPOST_URL_SECURE}"
echo " Skip Namespaces: ${SKIP_NAMESPACES}"
echo " Commander URL: ${COMMANDER_URL}"
echo " Insecure Skip Verify: ${INSECURE_SKIP_VERIFY}"
echo ""
# Show the helm command
print_color "$BOLD$BRIGHT_GREEN" "Helm command that will be executed:"
print_color "$GREEN" "helm install ${RELEASE_NAME} ${HELM_CHART} \\"
print_color "$GREEN" " --namespace ${NAMESPACE} \\"
if [[ "$CREATE_NAMESPACE" == "true" ]]; then
print_color "$GREEN" " --create-namespace \\"
fi
print_color "$GREEN" " --set outpost.env[0].name=COMPANY_ID \\"
print_color "$GREEN" " --set outpost.env[0].value=${COMPANY_ID} \\"
print_color "$GREEN" " --set outpost.env[1].name=AIOSTACK_VALIDATION_KEY \\"
print_color "$GREEN" " --set outpost.env[1].value=[HIDDEN] \\"
print_color "$GREEN" " ... (and additional outpost.env and observer.env variables) \\"
print_color "$GREEN" " --set observer.env[9].name=IS_OUTPOST_URL_SECURE \\"
print_color "$GREEN" " --set observer.env[9].value=${IS_OUTPOST_URL_SECURE} \\"
print_color "$GREEN" " --set observer.version=${OBSERVER_VERSION} \\"
print_color "$GREEN" " --set outpost.version=${OUTPOST_VERSION}"
echo ""
# Ask if user wants to save configuration
if ask_yes_no "Save this configuration for future use?" "y"; then
save_config
fi
echo ""
if ! ask_yes_no "Proceed with installation?" "y"; then
print_warning "Installation cancelled by user"
exit 0
fi
}
# Save configuration
save_config() {
local config_file="aiostack-config-$(date +%Y%m%d-%H%M%S).yaml"
cat > "$config_file" << EOF
# AIOStack Configuration
# Generated: $(date)
# DO NOT SHARE THIS FILE - IT CONTAINS SENSITIVE CREDENTIALS
namespace: ${NAMESPACE}
releaseName: ${RELEASE_NAME}
companyId: ${COMPANY_ID}
validationKey: ${VALIDATION_KEY}
isOutpostUrlSecure: ${IS_OUTPOST_URL_SECURE}
skipNamespaces: ${SKIP_NAMESPACES}
commanderUrl: ${COMMANDER_URL}
insecureSkipVerify: ${INSECURE_SKIP_VERIFY}
createNamespace: ${CREATE_NAMESPACE}
EOF
chmod 600 "$config_file"
print_success "Configuration saved to: ${config_file}"
print_warning "Keep this file secure - it contains sensitive credentials!"
}
# Load configuration
load_config() {
local config_file=$1
if [[ ! -f "$config_file" ]]; then
print_error "Configuration file not found: ${config_file}"
exit 1
fi
print_info "Loading configuration from: ${config_file}"
# Source the config file
while IFS=': ' read -r key value; do
# Skip comments and empty lines
[[ "$key" =~ ^#.*$ ]] && continue
[[ -z "$key" ]] && continue
case "$key" in
namespace) NAMESPACE="$value" ;;
releaseName) RELEASE_NAME="$value" ;;
companyId) COMPANY_ID="$value" ;;
validationKey) VALIDATION_KEY="$value" ;;
isOutpostUrlSecure) IS_OUTPOST_URL_SECURE="$value" ;;
skipNamespaces) SKIP_NAMESPACES="$value" ;;
commanderUrl) COMMANDER_URL="$value" ;;
insecureSkipVerify) INSECURE_SKIP_VERIFY="$value" ;;
createNamespace) CREATE_NAMESPACE="$value" ;;
esac
done < "$config_file"
print_success "Configuration loaded successfully"
}
# Install AIOStack
install_aurva() {
print_step "Installing AIOStack"
INSTALLATION_STARTED=true
# Create namespace if needed
if [[ "$CREATE_NAMESPACE" == "true" ]]; then
print_info "Creating namespace: ${NAMESPACE}"
if kubectl create namespace "$NAMESPACE" &> /dev/null; then
print_success "Namespace created"
NAMESPACE_CREATED=true
else
print_error "Failed to create namespace"
exit 1
fi
fi
echo ""
print_info "Starting Helm installation..."
print_info "This may take a few minutes..."
echo ""
# Build helm command with proper value overrides
local helm_cmd=(
helm install "$RELEASE_NAME" "$HELM_CHART"
--namespace "$NAMESPACE"
)
# Escape commas in SKIP_NAMESPACES for Helm (Helm treats commas as array separators)
local skip_namespaces_escaped="${SKIP_NAMESPACES//,/\\,}"
# Add values - we need to set ALL env variables for outpost and observer because --set replaces the entire array
helm_cmd+=(
--set "outpost.env[0].name=SKIP_NAMESPACES"
--set "outpost.env[0].value=${skip_namespaces_escaped}"
--set "outpost.env[1].name=INSECURE_SKIP_VERIFY"
--set "outpost.env[1].value=${INSECURE_SKIP_VERIFY}"
--set "outpost.env[2].name=COMMANDER_URL"
--set "outpost.env[2].value=${COMMANDER_URL}"
--set "outpost.env[3].name=COMPANY_ID"
--set "outpost.env[3].value=${COMPANY_ID}"
--set "outpost.env[4].name=AIOSTACK_VALIDATION_KEY"
--set "outpost.env[4].value=${VALIDATION_KEY}"
--set "observer.env[0].name=TRACE_SSL"
--set "observer.env[0].value=true"
--set "observer.env[1].name=TRACE_EGRESS"
--set "observer.env[1].value=true"
--set "observer.env[2].name=TRACE_GO_TLS"
--set "observer.env[2].value=true"
--set "observer.env[3].name=TRACE_INTERNAL_SVC"
--set "observer.env[3].value=true"
--set "observer.env[4].name=INTERNAL_SVC_SAMPLE_INTERVAL"
--set "observer.env[4].value=0s"
--set "observer.env[5].name=LOGS_TTL"
--set "observer.env[5].value=30s"
--set "observer.env[6].name=TRACE_INTERNAL_SVC_HTTP"
--set "observer.env[6].value=true"
--set "observer.env[7].name=INTERNAL_SVC_HTTP_SAMPLE_INTERVAL"
--set "observer.env[7].value=0s"
--set "observer.env[8].name=CONNECTION_CHANNEL_SIZE"
--set "observer.env[8].value=100"
--set "observer.env[9].name=IS_OUTPOST_URL_SECURE"
--set "observer.env[9].value=${IS_OUTPOST_URL_SECURE}"
--set "observer.version=${OBSERVER_VERSION}"
--set "outpost.version=${OUTPOST_VERSION}"
)
print_verbose "Running: ${helm_cmd[*]}"
# Execute helm install
if "${helm_cmd[@]}"; then
echo ""
print_success "Helm installation completed successfully!"
else
echo ""
print_error "Helm installation failed"
print_info "Run 'helm list -n ${NAMESPACE}' to check installation status"
exit 1
fi
}
# Verify deployment
verify_deployment() {
print_step "Verifying Deployment"
echo ""
print_info "Checking pod status..."
echo ""
# Wait a bit for pods to start
sleep 3
# Show pod status
kubectl get pods -n "$NAMESPACE" -l "app.kubernetes.io/instance=${RELEASE_NAME}" || true
echo ""
print_info "Waiting for pods to be ready (timeout: 5 minutes)..."
# Wait for pods with timeout
local timeout=300
local elapsed=0
local all_ready=false
while [[ $elapsed -lt $timeout ]]; do
local ready_count
local total_count
# Use jsonpath to reliably count ready pods
ready_count=$(kubectl get pods -n "$NAMESPACE" -l "app.kubernetes.io/instance=${RELEASE_NAME}" \
-o jsonpath='{range .items[*]}{.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}' 2>/dev/null | \
grep -c "True" 2>/dev/null || echo "0")
total_count=$(kubectl get pods -n "$NAMESPACE" -l "app.kubernetes.io/instance=${RELEASE_NAME}" \
--no-headers 2>/dev/null | wc -l 2>/dev/null | tr -d '[:space:]' || echo "0")
# Default to 0 if empty and trim any whitespace
ready_count=$(echo "$ready_count" | tr -d '[:space:]')
total_count=$(echo "$total_count" | tr -d '[:space:]')
ready_count=${ready_count:-0}
total_count=${total_count:-0}
if [[ $ready_count -gt 0 ]] && [[ $ready_count -eq $total_count ]]; then
all_ready=true
break
fi
printf "\r${GREEN}Pods ready: ${ready_count}/${total_count} (${elapsed}s elapsed)${NC}"
sleep 5
elapsed=$((elapsed + 5))
done
echo ""
echo ""
if [[ "$all_ready" == "true" ]]; then
print_success "All pods are ready!"
else
print_warning "Some pods are not ready yet. This is normal and they may need more time."
print_info "Monitor progress with: kubectl get pods -n ${NAMESPACE} -w"
fi
echo ""
print_color "$BOLD$BRIGHT_GREEN" "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
print_color "$BOLD$BRIGHT_GREEN" "Installation Complete!"
print_color "$BOLD$BRIGHT_GREEN" "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
print_info "Next Steps:"
echo ""
print_color "$BOLD" "1. Access the dashboard:"
echo " Visit: https://app.aurva.ai"
echo " Login with your email and credentials"
echo ""
print_color "$BOLD" "2. Monitor your installation:"
echo " kubectl get pods -n ${NAMESPACE}"
echo " kubectl logs -n ${NAMESPACE} -l app.kubernetes.io/instance=${RELEASE_NAME} --all-containers --tail=50"
echo ""
print_color "$BOLD" "3. Check service status:"
echo " kubectl get svc -n ${NAMESPACE}"
echo ""
print_color "$BOLD" "Useful commands:"
echo " # View all resources"
echo " kubectl get all -n ${NAMESPACE}"
echo ""
echo " # View logs"
echo " kubectl logs -n ${NAMESPACE} -l app.kubernetes.io/name=observer --tail=100"
echo " kubectl logs -n ${NAMESPACE} -l app.kubernetes.io/name=outpost --tail=100"
echo ""
echo " # Uninstall"
echo " helm uninstall ${RELEASE_NAME} -n ${NAMESPACE}"
echo ""
print_success "Thank you for installing AIOStack!"
print_info "Documentation: https://aurva.ai/docs/home"
print_info "Support: [email protected]"
}
# Cleanup on failure
cleanup_on_failure() {
echo ""
print_error "Installation failed. Initiating cleanup..."
# Remove helm release if installation started
if [[ "$INSTALLATION_STARTED" == "true" ]]; then
print_info "Removing helm release: ${RELEASE_NAME}"
helm uninstall "$RELEASE_NAME" -n "$NAMESPACE" &> /dev/null || true
fi
# Delete namespace if we created it
if [[ "$NAMESPACE_CREATED" == "true" ]]; then
print_info "Deleting namespace: ${NAMESPACE}"
kubectl delete namespace "$NAMESPACE" &> /dev/null || true
fi
# Remove helm repo if we added it
if [[ "$HELM_REPO_ADDED" == "true" ]]; then
print_info "Removing helm repository"
helm repo remove "$HELM_REPO_NAME" &> /dev/null || true
fi
print_success "Cleanup completed"
echo ""
print_info "Please check the error messages above and try again."
print_info "For help, visit: https://aurva.ai/docs/installation/steps"
exit 1
}
# Signal handler for cleanup
handle_interrupt() {
echo ""
print_warning "Installation interrupted by user"
if ask_yes_no "Do you want to clean up partial installation?" "y"; then
cleanup_on_failure
else
print_info "Partial installation left in place"
print_info "To clean up manually, run: helm uninstall ${RELEASE_NAME} -n ${NAMESPACE}"
fi
exit 130
}
#############################################################################
# Main
#############################################################################
main() {
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
show_help
;;
-v|--verbose)
VERBOSE="true"
shift
;;
-c|--config)
CONFIG_FILE="$2"
shift 2
;;
--version)
echo "AIOStack Installer v${VERSION}"
exit 0
;;
*)
print_error "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
# Set up signal handlers
trap handle_interrupt SIGINT SIGTERM
# Show banner
print_banner
# Load config if provided
if [[ -n "$CONFIG_FILE" ]]; then
load_config "$CONFIG_FILE"
echo ""
fi
# Run installation steps
check_prerequisites
setup_helm_repo
# Skip credential collection if loaded from config
if [[ -z "$COMPANY_ID" ]] || [[ -z "$VALIDATION_KEY" ]]; then
collect_credentials
else
print_info "Using credentials from config file"
fi
configure_namespace
collect_env_config
review_config
install_aurva
verify_deployment
}
# Run main function
main "$@"