Files
kubernetes/bootstrap_server.sh
2026-07-18 12:00:33 +05:30

68 lines
2.0 KiB
Bash

#!/bin/bash
set -e
# ==========================================
# 🚀 100gb-server Fresh Setup Script
# Use this script on a FRESH Ubuntu/Debian VPS
# to install Kubernetes (K3s) and prepare for deployment.
# ==========================================
echo "Started bootstrapping server..."
# 1. Update System
echo "🔄 Updating system packages..."
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y curl git unzip htop
# 2. Install K3s (Lightweight Kubernetes)
if ! command -v k3s &> /dev/null; then
echo "🏗️ Installing K3s..."
curl -sfL https://get.k3s.io | sh -
# Wait for K3s to start
echo "⏳ Waiting for K3s to be ready..."
sleep 15
else
echo "✅ K3s is already installed."
fi
# 3. Configure kubectl for the current user
echo "🔑 Configuring kubectl access..."
mkdir -p $HOME/.kube
sudo cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
echo "export KUBECONFIG=$HOME/.kube/config" >> $HOME/.bashrc
# Export for current session as well
export KUBECONFIG=$HOME/.kube/config
# 4. Install Helm (Package Manager)
if ! command -v helm &> /dev/null; then
echo "⚓ Installing Helm..."
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
else
echo "✅ Helm is already installed."
fi
# 5. Install basic tools (optional but recommended)
# Install K9s (Terminal UI for K8s) - useful for debugging
if ! command -v k9s &> /dev/null; then
echo "🖥️ Installing K9s..."
curl -sS https://webinstall.dev/k9s | bash
# Source the new path
export PATH="$HOME/.local/bin:$PATH"
fi
echo ""
echo "=========================================="
echo "✅ Server Setup Complete!"
echo "=========================================="
echo "To finish setup, restart your shell or run:"
echo " source ~/.bashrc"
echo ""
echo "To deploy your stacks, run:"
echo " ./deploy-core-stack.sh"
echo " ./deploy-nearle-stack.sh"
echo " ./deploy-alaska.sh"
echo "=========================================="