Implemented a production-ready K3s Kubernetes installer with full lifecycle support including installation, startup management, and cleanup. Key features: - Install first master (cluster init), join additional masters (HA), and workers - Systemd service management via StartupManager abstraction - IPv6 support with Mycelium interface auto-detection - Robust destroy/cleanup with proper ordering to prevent hanging - Complete removal of services, processes, network interfaces, and data
55 lines
2.0 KiB
Plaintext
55 lines
2.0 KiB
Plaintext
#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run
|
|
|
|
import incubaid.herolib.core.playcmds
|
|
import incubaid.herolib.ui.console
|
|
|
|
// ============================================================================
|
|
// K3s Join Additional Master (HA Setup)
|
|
// ============================================================================
|
|
// This script shows how to join an additional master node to an existing
|
|
// K3s cluster for high availability.
|
|
//
|
|
// Prerequisites:
|
|
// 1. First master must be running
|
|
// 2. You need the token from the first master
|
|
// 3. You need the master URL (IPv6 address and port)
|
|
// ============================================================================
|
|
|
|
console.print_header('='.repeat(80))
|
|
console.print_header('K3s Join Additional Master Node')
|
|
console.print_header('='.repeat(80))
|
|
|
|
// IMPORTANT: Replace these values with your actual cluster information
|
|
// You can get these from the first master's join script or by running:
|
|
// !!kubernetes_installer.generate_join_script name:"k3s_master_1"
|
|
|
|
master_token := 'YOUR_CLUSTER_TOKEN_HERE' // Get from first master
|
|
master_url := 'https://[YOUR_MASTER_IPV6]:6443' // First master's IPv6 address
|
|
|
|
join_master_script := '
|
|
!!kubernetes_installer.configure
|
|
name:"k3s_master_2"
|
|
k3s_version:"v1.33.1"
|
|
data_dir:"~/hero/var/k3s"
|
|
node_name:"master-2"
|
|
mycelium_interface:"mycelium"
|
|
token:"${master_token}"
|
|
master_url:"${master_url}"
|
|
|
|
!!kubernetes_installer.join_master name:"k3s_master_2"
|
|
|
|
!!kubernetes_installer.start name:"k3s_master_2"
|
|
'
|
|
|
|
console.print_header('⚠️ Before running, make sure to:')
|
|
console.print_header(' 1. Update master_token with your cluster token')
|
|
console.print_header(' 2. Update master_url with your first master IPv6')
|
|
console.print_header(' 3. Ensure first master is running')
|
|
console.print_header('')
|
|
|
|
// Uncomment the line below to actually run the join
|
|
// playcmds.run(heroscript: join_master_script)!
|
|
|
|
console.print_header('✅ Script ready. Uncomment playcmds.run() to execute.')
|
|
console.print_header('='.repeat(80))
|