reorder and clean repo
This commit is contained in:
@@ -0,0 +1 @@
|
||||
group_enable=cpuset cgroup_enable=memory cgroup_memory=1
|
||||
@@ -0,0 +1,72 @@
|
||||
AUTO_SETUP_ACCEPT_LICENSE=1
|
||||
AUTO_SETUP_LOCALE=C.UTF-8
|
||||
AUTO_SETUP_KEYBOARD_LAYOUT=us
|
||||
AUTO_SETUP_TIMEZONE=Europe/Amsterdam
|
||||
AUTO_SETUP_NET_ETHERNET_ENABLED=1
|
||||
AUTO_SETUP_NET_WIFI_ENABLED=0
|
||||
AUTO_SETUP_NET_ETH_FORCE_SPEED=0
|
||||
AUTO_SETUP_NET_WIFI_COUNTRY_CODE=NL
|
||||
|
||||
AUTO_SETUP_NET_HOSTNAME=turing3
|
||||
|
||||
AUTO_SETUP_BOOT_WAIT_FOR_NETWORK=1
|
||||
AUTO_SETUP_SWAPFILE_SIZE=1
|
||||
AUTO_SETUP_SWAPFILE_LOCATION=/var/swap
|
||||
AUTO_SETUP_HEADLESS=1
|
||||
AUTO_UNMASK_LOGIND=0
|
||||
AUTO_SETUP_CUSTOM_SCRIPT_EXEC=0
|
||||
AUTO_SETUP_BACKUP_RESTORE=0
|
||||
AUTO_SETUP_SSH_SERVER_INDEX=-2
|
||||
AUTO_SETUP_LOGGING_INDEX=-1
|
||||
AUTO_SETUP_RAMLOG_MAXSIZE=50
|
||||
|
||||
AUTO_SETUP_WEB_SERVER_INDEX=0
|
||||
AUTO_SETUP_DESKTOP_INDEX=0
|
||||
AUTO_SETUP_BROWSER_INDEX=0
|
||||
AUTO_SETUP_AUTOSTART_TARGET_INDEX=7
|
||||
AUTO_SETUP_AUTOSTART_LOGIN_USER=root
|
||||
AUTO_SETUP_GLOBAL_PASSWORD=turing
|
||||
AUTO_SETUP_AUTOMATED=1
|
||||
SURVEY_OPTED_IN=0
|
||||
|
||||
#OpenSSH Client
|
||||
AUTO_SETUP_INSTALL_SOFTWARE_ID=0
|
||||
#Samba Client
|
||||
AUTO_SETUP_INSTALL_SOFTWARE_ID=1
|
||||
#vim
|
||||
AUTO_SETUP_INSTALL_SOFTWARE_ID=20
|
||||
#RPi.GPIO
|
||||
AUTO_SETUP_INSTALL_SOFTWARE_ID=69
|
||||
#OpenSSH Server
|
||||
AUTO_SETUP_INSTALL_SOFTWARE_ID=105
|
||||
#Python 3 pip
|
||||
AUTO_SETUP_INSTALL_SOFTWARE_ID=130
|
||||
|
||||
CONFIG_CPU_GOVERNOR=schedutil
|
||||
CONFIG_CPU_ONDEMAND_SAMPLE_RATE=25000
|
||||
CONFIG_CPU_ONDEMAND_SAMPLE_DOWNFACTOR=40
|
||||
CONFIG_CPU_USAGE_THROTTLE_UP=50
|
||||
|
||||
CONFIG_CPU_MAX_FREQ=Disabled
|
||||
CONFIG_CPU_MIN_FREQ=Disabled
|
||||
|
||||
CONFIG_CPU_DISABLE_TURBO=0
|
||||
|
||||
CONFIG_G_CHECK_URL_TIMEOUT=10
|
||||
CONFIG_G_CHECK_URL_ATTEMPTS=5
|
||||
CONFIG_CHECK_CONNECTION_IP=8.8.8.8
|
||||
CONFIG_CHECK_CONNECTION_IPV6=2620:fe::fe
|
||||
CONFIG_CHECK_DNS_DOMAIN=google.com
|
||||
|
||||
CONFIG_CHECK_DIETPI_UPDATES=1
|
||||
CONFIG_CHECK_APT_UPDATES=1
|
||||
CONFIG_NTP_MODE=2
|
||||
CONFIG_SERIAL_CONSOLE_ENABLE=1
|
||||
CONFIG_SOUNDCARD=none
|
||||
CONFIG_LCDPANEL=none
|
||||
CONFIG_ENABLE_IPV6=0
|
||||
|
||||
CONFIG_APT_RASPBIAN_MIRROR=http://raspbian.raspberrypi.org/raspbian/
|
||||
CONFIG_APT_DEBIAN_MIRROR=https://deb.debian.org/debian/
|
||||
CONFIG_NTP_MIRROR=debian.pool.ntp.org
|
||||
SOFTWARE_DISABLE_SSH_PASSWORD_LOGINS=0
|
||||
@@ -0,0 +1 @@
|
||||
curl -sfL https://get.k3s.io | K3S_URL=https://192.168.222.237:6443 K3S_TOKEN=torino sh -
|
||||
Executable
+180
@@ -0,0 +1,180 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Configuration
|
||||
MASTER_NODE="turing1"
|
||||
WORKER_NODES=("turing2" "turing3" "turing4")
|
||||
BEELINK_NODE="beelink.lan"
|
||||
MASTER_IP="192.168.222.237"
|
||||
TOKEN="torino"
|
||||
SSH_PASSWORD="turing"
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Function to check if sshpass is available
|
||||
check_dependencies() {
|
||||
if ! command -v sshpass &> /dev/null; then
|
||||
print_warning "sshpass not found, installing..."
|
||||
if command -v pacman &> /dev/null; then
|
||||
sudo pacman -S sshpass --noconfirm
|
||||
elif command -v apt-get &> /dev/null; then
|
||||
sudo apt-get update && sudo apt-get install -y sshpass
|
||||
else
|
||||
print_error "Cannot install sshpass automatically. Please install it manually."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to upgrade master node
|
||||
upgrade_master() {
|
||||
print_status "Upgrading master node: $MASTER_NODE"
|
||||
|
||||
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no root@$MASTER_NODE '
|
||||
curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_DOWNLOAD=false sh -s - \
|
||||
--write-kubeconfig-mode 644 \
|
||||
--disable servicelb \
|
||||
--token torino \
|
||||
--node-ip 192.168.222.237 \
|
||||
--disable-cloud-controller \
|
||||
--disable local-storage
|
||||
'
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_status "Master node $MASTER_NODE upgraded successfully"
|
||||
else
|
||||
print_error "Failed to upgrade master node $MASTER_NODE"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to upgrade worker nodes
|
||||
upgrade_worker() {
|
||||
local node=$1
|
||||
print_status "Upgrading worker node: $node"
|
||||
|
||||
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no root@$node "
|
||||
curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_DOWNLOAD=false \
|
||||
K3S_URL=https://$MASTER_IP:6443 \
|
||||
K3S_TOKEN=$TOKEN sh -
|
||||
"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_status "Worker node $node upgraded successfully"
|
||||
else
|
||||
print_error "Failed to upgrade worker node $node"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to upgrade beelink node
|
||||
upgrade_beelink() {
|
||||
print_status "Upgrading beelink node: $BEELINK_NODE"
|
||||
|
||||
ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no gilgamezh@$BEELINK_NODE "
|
||||
sudo curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_DOWNLOAD=false \
|
||||
K3S_URL=https://$MASTER_IP:6443 \
|
||||
K3S_TOKEN=$TOKEN sh -
|
||||
"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_status "Beelink node $BEELINK_NODE upgraded successfully"
|
||||
else
|
||||
print_error "Failed to upgrade beelink node $BEELINK_NODE"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to verify cluster health
|
||||
verify_cluster() {
|
||||
print_status "Verifying cluster health..."
|
||||
|
||||
# Wait a moment for nodes to register
|
||||
sleep 10
|
||||
|
||||
print_status "Cluster nodes:"
|
||||
kubectl get nodes
|
||||
|
||||
print_status "Checking for unhealthy pods..."
|
||||
unhealthy_pods=$(kubectl get pods --all-namespaces | grep -v Running | grep -v Completed | wc -l)
|
||||
|
||||
if [ "$unhealthy_pods" -gt 1 ]; then # Greater than 1 because header line counts
|
||||
print_warning "Found unhealthy pods:"
|
||||
kubectl get pods --all-namespaces | grep -v Running | grep -v Completed
|
||||
else
|
||||
print_status "All pods are healthy"
|
||||
fi
|
||||
|
||||
print_status "Cluster upgrade completed successfully!"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
main() {
|
||||
print_status "Starting K3s cluster upgrade..."
|
||||
print_status "This will upgrade all nodes in the TuringPi cluster"
|
||||
|
||||
# Check dependencies
|
||||
check_dependencies
|
||||
|
||||
# Show current cluster state
|
||||
print_status "Current cluster state:"
|
||||
kubectl get nodes
|
||||
|
||||
read -p "Do you want to continue with the upgrade? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
print_status "Upgrade cancelled"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Upgrade master node first
|
||||
upgrade_master
|
||||
|
||||
# Wait a bit for master to stabilize
|
||||
sleep 15
|
||||
|
||||
# Upgrade worker nodes
|
||||
failed_workers=0
|
||||
for worker in "${WORKER_NODES[@]}"; do
|
||||
if ! upgrade_worker "$worker"; then
|
||||
((failed_workers++))
|
||||
fi
|
||||
sleep 5 # Brief pause between worker upgrades
|
||||
done
|
||||
|
||||
# Upgrade beelink node
|
||||
if ! upgrade_beelink; then
|
||||
print_warning "Beelink node upgrade failed, but continuing..."
|
||||
fi
|
||||
|
||||
# Verify cluster health
|
||||
verify_cluster
|
||||
|
||||
if [ $failed_workers -gt 0 ]; then
|
||||
print_warning "Upgrade completed with $failed_workers failed worker node(s)"
|
||||
exit 1
|
||||
else
|
||||
print_status "All nodes upgraded successfully!"
|
||||
fi
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user