Initial commit: loc_az_hci (smom-dbis-138 excluded via .gitignore)
Some checks failed
Test / test (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
83
scripts/infrastructure/setup-k3s.sh
Executable file
83
scripts/infrastructure/setup-k3s.sh
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/bin/bash
|
||||
source ~/.bashrc
|
||||
# K3s Installation Script
|
||||
# Run this on the K3s VM after OS installation
|
||||
|
||||
set -e
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
log_step() {
|
||||
echo -e "${BLUE}[STEP]${NC} $1"
|
||||
}
|
||||
|
||||
# Check if running as root
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
log_error "Please run as root (use sudo)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_step "Step 1: Installing K3s..."
|
||||
curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--write-kubeconfig-mode 644" sh -
|
||||
|
||||
log_step "Step 2: Verifying K3s installation..."
|
||||
systemctl status k3s --no-pager || log_error "K3s service not running"
|
||||
|
||||
log_step "Step 3: Waiting for K3s to be ready..."
|
||||
sleep 10
|
||||
kubectl get nodes || log_warn "K3s may still be initializing"
|
||||
|
||||
log_step "Step 4: Installing kubectl (if not present)..."
|
||||
if ! command -v kubectl &> /dev/null; then
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
chmod +x kubectl
|
||||
mv kubectl /usr/local/bin/
|
||||
fi
|
||||
|
||||
log_step "Step 5: Configuring kubectl..."
|
||||
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||
mkdir -p ~/.kube
|
||||
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
|
||||
chmod 600 ~/.kube/config
|
||||
|
||||
log_step "Step 6: Verifying cluster..."
|
||||
kubectl cluster-info
|
||||
kubectl get nodes
|
||||
|
||||
log_info "========================================="
|
||||
log_info "K3s Installation Complete!"
|
||||
log_info "========================================="
|
||||
echo ""
|
||||
log_info "K3s is ready to use!"
|
||||
echo ""
|
||||
log_info "Useful commands:"
|
||||
echo " kubectl get nodes"
|
||||
echo " kubectl get pods --all-namespaces"
|
||||
echo " kubectl cluster-info"
|
||||
echo ""
|
||||
log_warn "Next steps:"
|
||||
echo " 1. Create namespaces: kubectl create namespace blockchain"
|
||||
echo " 2. Deploy ingress controller"
|
||||
echo " 3. Deploy cert-manager"
|
||||
echo " 4. Deploy HC Stack services"
|
||||
echo ""
|
||||
log_info "Kubeconfig location: /etc/rancher/k3s/k3s.yaml"
|
||||
log_info "Copy this file to access cluster remotely"
|
||||
|
||||
Reference in New Issue
Block a user