Refactor wild-cluster-config-generate script; remove --force option and improve cluster secrets generation. Add wild-cluster-node-boot-assets-download script for downloading Talos installer images and assets. Update wild-setup-cluster to integrate new boot asset download process and adjust configuration steps. Clean up wild-setup-services and update documentation for clarity on new processes.
This commit is contained in:
@@ -11,7 +11,6 @@ usage() {
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -h, --help Show this help message"
|
echo " -h, --help Show this help message"
|
||||||
echo " --force Force regeneration even if config already exists"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "This script will:"
|
echo "This script will:"
|
||||||
echo " - Generate initial cluster secrets and configurations"
|
echo " - Generate initial cluster secrets and configurations"
|
||||||
@@ -19,8 +18,7 @@ usage() {
|
|||||||
echo " - Set up the foundation for node-specific machine configs"
|
echo " - Set up the foundation for node-specific machine configs"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Requirements:"
|
echo "Requirements:"
|
||||||
echo " - Must be run from a wild-cloud directory"
|
echo " - Must be run from a Wild Cloud home directory"
|
||||||
echo " - Cluster name and VIP must be configured"
|
|
||||||
echo " - talosctl must be available in PATH"
|
echo " - talosctl must be available in PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,10 +30,6 @@ while [[ $# -gt 0 ]]; do
|
|||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
--force)
|
|
||||||
FORCE=true
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-*)
|
-*)
|
||||||
echo "Unknown option $1"
|
echo "Unknown option $1"
|
||||||
usage
|
usage
|
||||||
@@ -68,92 +62,40 @@ print_header "Talos Cluster Configuration Generation"
|
|||||||
NODE_SETUP_DIR="${WC_HOME}/setup/cluster-nodes"
|
NODE_SETUP_DIR="${WC_HOME}/setup/cluster-nodes"
|
||||||
mkdir -p "${NODE_SETUP_DIR}/generated"
|
mkdir -p "${NODE_SETUP_DIR}/generated"
|
||||||
|
|
||||||
# Check if cluster configuration already exists
|
# Generate cluster secrets
|
||||||
|
|
||||||
if [ -f "${NODE_SETUP_DIR}/generated/secrets.yaml" ] && [ "$FORCE" = false ]; then
|
if [ -f "${NODE_SETUP_DIR}/generated/secrets.yaml" ] && [ "$FORCE" = false ]; then
|
||||||
print_success "Cluster configuration already exists"
|
print_success "Cluster secrets already exists in ${NODE_SETUP_DIR}/generated/"
|
||||||
print_info "Generated files:"
|
|
||||||
for file in "${NODE_SETUP_DIR}/generated"/*.yaml; do
|
|
||||||
if [ -f "$file" ]; then
|
|
||||||
print_info " - $(basename "$file")"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo ""
|
|
||||||
print_info "Use --force to regenerate cluster configuration"
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get cluster configuration
|
# Prepare directory for generated secrets
|
||||||
CLUSTER_NAME=$(get_current_config "cluster.name")
|
print_info "Generating new cluster secrets..."
|
||||||
VIP=$(get_current_config "cluster.nodes.control.vip")
|
if [ -d "${NODE_SETUP_DIR}/generated" ]; then
|
||||||
|
print_warning "Removing existing secrets directory..."
|
||||||
# Validate required configuration
|
rm -rf "${NODE_SETUP_DIR}/generated"
|
||||||
if [ -z "$CLUSTER_NAME" ] || [ "$CLUSTER_NAME" = "null" ]; then
|
|
||||||
print_error "Cluster name not configured"
|
|
||||||
print_info "Please run 'wild-setup' first to configure cluster.name"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
mkdir -p "${NODE_SETUP_DIR}/generated"
|
||||||
|
talosctl gen secrets
|
||||||
|
print_info "New secrets will be generated in ${NODE_SETUP_DIR}/generated/"
|
||||||
|
|
||||||
if [ -z "$VIP" ] || [ "$VIP" = "null" ]; then
|
# Ensure we have the configuration we need.
|
||||||
print_error "Control plane VIP not configured"
|
|
||||||
print_info "Please run 'wild-setup' first to configure cluster.nodes.control.vip"
|
prompt_if_unset_config "cluster.name" "Cluster name" "wild-cluster"
|
||||||
exit 1
|
CLUSTER_NAME=$(wild-config "cluster.name")
|
||||||
fi
|
|
||||||
|
prompt_if_unset_config "cluster.nodes.control.vip" "Control plane virtual IP (VIP)"
|
||||||
|
VIP=$(wild-config "cluster.nodes.control.vip")
|
||||||
|
|
||||||
# Generate cluster configuration
|
# Generate cluster configuration
|
||||||
print_info "Generating initial cluster configuration..."
|
print_info "Generating initial cluster configuration..."
|
||||||
print_info "Cluster name: $CLUSTER_NAME"
|
print_info "Cluster name: $CLUSTER_NAME"
|
||||||
print_info "Control plane endpoint: https://$VIP:6443"
|
print_info "Control plane endpoint: https://$VIP:6443"
|
||||||
|
|
||||||
if [ "$FORCE" = true ] && [ -d "${NODE_SETUP_DIR}/generated" ]; then
|
|
||||||
print_warning "Removing existing cluster configuration..."
|
|
||||||
rm -rf "${NODE_SETUP_DIR}/generated"
|
|
||||||
mkdir -p "${NODE_SETUP_DIR}/generated"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "${NODE_SETUP_DIR}/generated"
|
cd "${NODE_SETUP_DIR}/generated"
|
||||||
talosctl gen secrets
|
|
||||||
talosctl gen config --with-secrets secrets.yaml "$CLUSTER_NAME" "https://$VIP:6443"
|
talosctl gen config --with-secrets secrets.yaml "$CLUSTER_NAME" "https://$VIP:6443"
|
||||||
cd - >/dev/null
|
cd - >/dev/null
|
||||||
|
|
||||||
# Verify generated files
|
# Verify generated files
|
||||||
REQUIRED_FILES=("secrets.yaml" "controlplane.yaml" "worker.yaml" "talosconfig")
|
|
||||||
MISSING_FILES=()
|
|
||||||
|
|
||||||
for file in "${REQUIRED_FILES[@]}"; do
|
|
||||||
if [ ! -f "${NODE_SETUP_DIR}/generated/$file" ]; then
|
|
||||||
MISSING_FILES+=("$file")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ${#MISSING_FILES[@]} -gt 0 ]; then
|
|
||||||
print_error "Some required files were not generated:"
|
|
||||||
for file in "${MISSING_FILES[@]}"; do
|
|
||||||
print_error " - $file"
|
|
||||||
done
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
print_success "Cluster configuration generated successfully!"
|
|
||||||
echo ""
|
|
||||||
print_info "Generated files:"
|
|
||||||
for file in "${NODE_SETUP_DIR}/generated"/*.yaml "${NODE_SETUP_DIR}/generated/talosconfig"; do
|
|
||||||
if [ -f "$file" ]; then
|
|
||||||
filesize=$(du -h "$file" | cut -f1)
|
|
||||||
print_success " ✓ $(basename "$file") ($filesize)"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
print_info "Configuration details:"
|
|
||||||
print_info " - Cluster name: $CLUSTER_NAME"
|
|
||||||
print_info " - Control plane endpoint: https://$VIP:6443"
|
|
||||||
print_info " - Generated in: ${NODE_SETUP_DIR}/generated/"
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
print_info "Next steps:"
|
|
||||||
echo " 1. Node-specific machine configs can now be generated"
|
|
||||||
echo " 2. Use wild-cluster-node-machine-config-generate <ip> for each node"
|
|
||||||
echo " 3. Apply configs to nodes with talosctl apply-config"
|
|
||||||
echo " 4. Bootstrap the first control plane node"
|
|
||||||
|
|
||||||
print_success "Cluster configuration generation completed!"
|
print_success "Cluster configuration generation completed!"
|
@@ -5,7 +5,7 @@ set -o pipefail
|
|||||||
|
|
||||||
# Usage function
|
# Usage function
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: wild-cluster-node-image-create [options]"
|
echo "Usage: wild-cluster-node-boot-assets-download [options]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Generate custom Talos installer image URLs for cluster nodes."
|
echo "Generate custom Talos installer image URLs for cluster nodes."
|
||||||
echo ""
|
echo ""
|
@@ -105,7 +105,7 @@ if [ ! -f "${KERNEL_CACHE_PATH}" ] || [ ! -f "${INITRAMFS_CACHE_PATH}" ]; then
|
|||||||
echo " Kernel: ${KERNEL_CACHE_PATH}"
|
echo " Kernel: ${KERNEL_CACHE_PATH}"
|
||||||
echo " Initramfs: ${INITRAMFS_CACHE_PATH}"
|
echo " Initramfs: ${INITRAMFS_CACHE_PATH}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Please run 'wild-cluster-node-image-create' first to download and cache the assets."
|
echo "Please run 'wild-cluster-node-boot-assets-download' first to download and cache the assets."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ if [ ! -f "${IPXE_EFI_CACHE}" ] || [ ! -f "${IPXE_BIOS_CACHE}" ] || [ ! -f "${IP
|
|||||||
echo " iPXE BIOS: ${IPXE_BIOS_CACHE}"
|
echo " iPXE BIOS: ${IPXE_BIOS_CACHE}"
|
||||||
echo " iPXE ARM64: ${IPXE_ARM64_CACHE}"
|
echo " iPXE ARM64: ${IPXE_ARM64_CACHE}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Please run 'wild-cluster-node-image-create' first to download and cache the assets."
|
echo "Please run 'wild-cluster-node-boot-assets-download' first to download and cache the assets."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@@ -66,22 +66,31 @@ else
|
|||||||
init_wild_env
|
init_wild_env
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check basic configuration
|
|
||||||
check_basic_config
|
|
||||||
|
|
||||||
print_header "Wild Cloud Cluster Setup"
|
print_header "Wild Cloud Cluster Setup"
|
||||||
print_info "Setting up cluster infrastructure"
|
print_info "Setting up cluster infrastructure"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# =============================================================================
|
# Generate initial cluster configuration
|
||||||
|
|
||||||
|
wild-cluster-config-generate
|
||||||
|
|
||||||
|
# Configure Talos cli with our new cluster context
|
||||||
|
|
||||||
|
HAS_CONTEXT=$(talos config get | grep -c "<cluster.name>")
|
||||||
|
if [ "$HAS_CONTEXT" -eq 0 ]; then
|
||||||
|
print_info "No Talos context found for cluster <cluster.name>, creating..."
|
||||||
|
talos config merge ${WC_HOME}/setup/cluster-nodes/generated/talosconfig
|
||||||
|
talos config use <cluster.name>
|
||||||
|
print_success "Talos context for <cluster.name> created and set as current"
|
||||||
|
fi
|
||||||
|
|
||||||
# Talos asset download
|
# Talos asset download
|
||||||
# =============================================================================
|
|
||||||
|
|
||||||
if [ "${SKIP_INSTALLER}" = false ]; then
|
if [ "${SKIP_INSTALLER}" = false ]; then
|
||||||
print_header "Installer Image Generation"
|
print_header "Installer Image Generation"
|
||||||
|
|
||||||
print_info "Running wild-cluster-node-image-create..."
|
print_info "Running wild-cluster-node-boot-assets-download..."
|
||||||
wild-cluster-node-image-create
|
wild-cluster-node-boot-assets-download
|
||||||
|
|
||||||
print_success "Installer image generated"
|
print_success "Installer image generated"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -90,36 +99,21 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Network and Cluster Configuration
|
# Configuration
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
prompt_if_unset_config "owner.email" "Owner email address"
|
||||||
|
|
||||||
# Configure network settings
|
# Configure network settings
|
||||||
if [ -z "$(get_current_config "cloud.router.ip")" ]; then
|
|
||||||
print_header "Network Configuration"
|
|
||||||
|
|
||||||
CURRENT_IP=$(ip route get 8.8.8.8 | awk '{print $7; exit}' 2>/dev/null || echo "192.168.1.100")
|
|
||||||
GATEWAY_IP=$(ip route | grep default | awk '{print $3; exit}' 2>/dev/null || echo "192.168.1.1")
|
|
||||||
SUBNET_PREFIX=$(echo "${CURRENT_IP}" | cut -d. -f1-3)
|
|
||||||
|
|
||||||
prompt_if_unset_config "cloud.router.ip" "Router/Gateway IP" "${GATEWAY_IP}"
|
|
||||||
prompt_if_unset_config "cloud.dns.ip" "DNS server IP (dnsmasq machine)" "${SUBNET_PREFIX}.50"
|
|
||||||
prompt_if_unset_config "cloud.dhcpRange" "DHCP range for dnsmasq" "${SUBNET_PREFIX}.100,${SUBNET_PREFIX}.200"
|
|
||||||
prompt_if_unset_config "cloud.dnsmasq.interface" "Network interface for dnsmasq" "eth0"
|
|
||||||
prompt_if_unset_config "cloud.dns.externalResolver" "External DNS resolver" "1.1.1.1"
|
|
||||||
|
|
||||||
print_success "Network configuration completed"
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Configure cluster settings
|
|
||||||
print_header "Kubernetes Cluster Configuration"
|
|
||||||
|
|
||||||
CURRENT_IP=$(ip route get 8.8.8.8 | awk '{print $7; exit}' 2>/dev/null || echo "192.168.1.100")
|
CURRENT_IP=$(ip route get 8.8.8.8 | awk '{print $7; exit}' 2>/dev/null || echo "192.168.1.100")
|
||||||
|
GATEWAY_IP=$(ip route | grep default | awk '{print $3; exit}' 2>/dev/null || echo "192.168.1.1")
|
||||||
SUBNET_PREFIX=$(echo "${CURRENT_IP}" | cut -d. -f1-3)
|
SUBNET_PREFIX=$(echo "${CURRENT_IP}" | cut -d. -f1-3)
|
||||||
|
|
||||||
# Talos version
|
prompt_if_unset_config "cloud.router.ip" "Router/Gateway IP" "${GATEWAY_IP}"
|
||||||
prompt_if_unset_config "cluster.nodes.talos.version" "Talos version" "v1.10.4"
|
prompt_if_unset_config "cloud.dns.ip" "DNS server IP (dnsmasq machine)" "${SUBNET_PREFIX}.50"
|
||||||
talos_version=$(wild-config "cluster.nodes.talos.version")
|
prompt_if_unset_config "cloud.dhcpRange" "DHCP range for dnsmasq" "${SUBNET_PREFIX}.100,${SUBNET_PREFIX}.200"
|
||||||
|
prompt_if_unset_config "cloud.dnsmasq.interface" "Network interface for dnsmasq" "eth0"
|
||||||
|
prompt_if_unset_config "cloud.dns.externalResolver" "External DNS resolver" "1.1.1.1"
|
||||||
|
|
||||||
# MetalLB IP address pool
|
# MetalLB IP address pool
|
||||||
prompt_if_unset_config "cluster.ipAddressPool" "MetalLB IP address pool" "${SUBNET_PREFIX}.80-${SUBNET_PREFIX}.89"
|
prompt_if_unset_config "cluster.ipAddressPool" "MetalLB IP address pool" "${SUBNET_PREFIX}.80-${SUBNET_PREFIX}.89"
|
||||||
@@ -133,6 +127,10 @@ if [ -z "$current_lb_ip" ] || [ "$current_lb_ip" = "null" ]; then
|
|||||||
print_info "Set load balancer IP to: ${lb_ip} (first IP in MetalLB pool)"
|
print_info "Set load balancer IP to: ${lb_ip} (first IP in MetalLB pool)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Talos version
|
||||||
|
prompt_if_unset_config "cluster.nodes.talos.version" "Talos version" "v1.10.4"
|
||||||
|
talos_version=$(wild-config "cluster.nodes.talos.version")
|
||||||
|
|
||||||
# Talos schematic ID
|
# Talos schematic ID
|
||||||
current_schematic_id=$(get_current_config "cluster.nodes.talos.schematicId")
|
current_schematic_id=$(get_current_config "cluster.nodes.talos.schematicId")
|
||||||
if [ -z "$current_schematic_id" ] || [ "$current_schematic_id" = "null" ]; then
|
if [ -z "$current_schematic_id" ] || [ "$current_schematic_id" = "null" ]; then
|
||||||
@@ -156,27 +154,15 @@ fi
|
|||||||
cluster_name=$(get_current_config "cluster.name")
|
cluster_name=$(get_current_config "cluster.name")
|
||||||
prompt_if_unset_config "cluster.externalDns.ownerId" "External DNS owner ID" "external-dns-${cluster_name}"
|
prompt_if_unset_config "cluster.externalDns.ownerId" "External DNS owner ID" "external-dns-${cluster_name}"
|
||||||
|
|
||||||
print_success "Cluster configuration completed"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Node Hardware Detection
|
# Node setup
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
if [ "${SKIP_HARDWARE}" = false ]; then
|
if [ "${SKIP_HARDWARE}" = false ]; then
|
||||||
print_header "Node Hardware Detection"
|
|
||||||
|
|
||||||
print_info "This phase will help you register Talos nodes by discovering their hardware."
|
print_header "Control Plane Configuration"
|
||||||
print_info "You'll need nodes booted in maintenance mode and accessible via IP."
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Configure control plane network topology first
|
|
||||||
if [ -z "$(get_current_config "cluster.nodes.control.vip")" ]; then
|
|
||||||
print_header "Control Plane Network Configuration"
|
|
||||||
|
|
||||||
# Detect current network for suggestions
|
|
||||||
CURRENT_IP=$(ip route get 8.8.8.8 | awk '{print $7; exit}' 2>/dev/null || echo "192.168.1.100")
|
|
||||||
SUBNET_PREFIX=$(echo "${CURRENT_IP}" | cut -d. -f1-3)
|
|
||||||
|
|
||||||
print_info "Configure control plane nodes (you need at least 3 for HA):"
|
print_info "Configure control plane nodes (you need at least 3 for HA):"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -188,45 +174,20 @@ if [ "${SKIP_HARDWARE}" = false ]; then
|
|||||||
vip_last_octet=$(echo "$vip" | cut -d. -f4)
|
vip_last_octet=$(echo "$vip" | cut -d. -f4)
|
||||||
vip_prefix=$(echo "$vip" | cut -d. -f1-3)
|
vip_prefix=$(echo "$vip" | cut -d. -f1-3)
|
||||||
|
|
||||||
print_info "Configuring control plane nodes using consecutive IPs after VIP:"
|
|
||||||
for i in 1 2 3; do
|
|
||||||
node_ip="${vip_prefix}.$(( vip_last_octet + i ))"
|
|
||||||
print_info " Control plane node $i: $node_ip"
|
|
||||||
|
|
||||||
# Initialize the node in cluster.nodes.active if not already present
|
|
||||||
if [ -z "$(get_current_config "cluster.nodes.active.\"${node_ip}\".control")" ]; then
|
|
||||||
wild-config-set "cluster.nodes.active.\"${node_ip}\".control" "true"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
print_success "Control plane network configuration completed"
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# # Generate initial cluster configuration
|
|
||||||
# print_header "Cluster Configuration Generation"
|
|
||||||
# print_info "Generating base cluster configuration with talosctl gen config..."
|
|
||||||
# wild-cluster-config-generate
|
|
||||||
|
|
||||||
# Detect and register control plane nodes
|
# Detect and register control plane nodes
|
||||||
print_header "Control Plane Node Registration"
|
print_header "Control Plane Node Registration"
|
||||||
|
|
||||||
# Get VIP to determine control plane IPs
|
|
||||||
vip=$(get_current_config "cluster.nodes.control.vip")
|
|
||||||
if [ -z "$vip" ]; then
|
|
||||||
print_error "VIP not configured. Run control plane network configuration first."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
vip_last_octet=$(echo "$vip" | cut -d. -f4)
|
|
||||||
vip_prefix=$(echo "$vip" | cut -d. -f1-3)
|
|
||||||
|
|
||||||
# Process each control plane node IP
|
# Process each control plane node IP
|
||||||
for i in 1 2 3; do
|
for i in 1 2 3; do
|
||||||
TARGET_IP="${vip_prefix}.$(( vip_last_octet + i ))"
|
TARGET_IP="${vip_prefix}.$(( vip_last_octet + i ))"
|
||||||
echo ""
|
echo ""
|
||||||
print_info "Registering control plane node: $TARGET_IP"
|
print_info "Registering control plane node: $TARGET_IP"
|
||||||
|
|
||||||
|
# Initialize the node in cluster.nodes.active if not already present
|
||||||
|
if [ -z "$(get_current_config "cluster.nodes.active.\"${TARGET_IP}\".control")" ]; then
|
||||||
|
wild-config-set "cluster.nodes.active.\"${TARGET_IP}\".control" "true"
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if node is already configured
|
# Check if node is already configured
|
||||||
existing_interface=$(get_current_config "cluster.nodes.active.\"${TARGET_IP}\".interface")
|
existing_interface=$(get_current_config "cluster.nodes.active.\"${TARGET_IP}\".interface")
|
||||||
if [ -n "$existing_interface" ] && [ "$existing_interface" != "null" ]; then
|
if [ -n "$existing_interface" ] && [ "$existing_interface" != "null" ]; then
|
||||||
@@ -234,25 +195,25 @@ if [ "${SKIP_HARDWARE}" = false ]; then
|
|||||||
print_info " - Interface: $existing_interface"
|
print_info " - Interface: $existing_interface"
|
||||||
print_info " - Disk: $(get_current_config "cluster.nodes.active.\"${TARGET_IP}\".disk")"
|
print_info " - Disk: $(get_current_config "cluster.nodes.active.\"${TARGET_IP}\".disk")"
|
||||||
|
|
||||||
# Generate machine config for this node if necessary.
|
# Generate machine config patch for this node if necessary.
|
||||||
NODE_SETUP_DIR="${WC_HOME}/setup/cluster-nodes"
|
NODE_SETUP_DIR="${WC_HOME}/setup/cluster-nodes"
|
||||||
CONFIG_FILE="${NODE_SETUP_DIR}/final/${TARGET_IP}.yaml"
|
CONFIG_FILE="${NODE_SETUP_DIR}/patch/${TARGET_IP}.yaml"
|
||||||
if [ ! -f "$CONFIG_FILE" ]; then
|
if [ ! -f "$CONFIG_FILE" ]; then
|
||||||
print_info "Generating missing machine configuration for $TARGET_IP..."
|
print_info "Generating missing machine configuration patch for $TARGET_IP..."
|
||||||
if wild-cluster-node-machine-config-generate "$TARGET_IP"; then
|
if wild-cluster-node-patch-generate "$TARGET_IP"; then
|
||||||
print_success "Machine configuration generated for $TARGET_IP"
|
print_success "Machine configuration patch generated for $TARGET_IP"
|
||||||
else
|
else
|
||||||
print_warning "Failed to generate machine configuration for $TARGET_IP"
|
print_warning "Failed to generate machine configuration patch for $TARGET_IP"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
print_info " ✓ Machine config exists: $CONFIG_FILE"
|
print_info " ✓ Machine configuration patch exists: $CONFIG_FILE"
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -p "Do you want to register control plane node $TARGET_IP now? (y/N): " -r register_node
|
read -p "Do you want to bring up control plane node $TARGET_IP now? (y/N): " -r register_node
|
||||||
if [[ ! $register_node =~ ^[Yy]$ ]]; then
|
if [[ ! $register_node =~ ^[Yy]$ ]]; then
|
||||||
print_info "Skipping node $TARGET_IP registration"
|
print_info "Skipping bringing up node $TARGET_IP registration"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -319,7 +280,6 @@ if [ "${SKIP_HARDWARE}" = false ]; then
|
|||||||
print_info "Updating configuration for $TARGET_IP..."
|
print_info "Updating configuration for $TARGET_IP..."
|
||||||
wild-config-set "cluster.nodes.active.\"${TARGET_IP}\".interface" "$INTERFACE"
|
wild-config-set "cluster.nodes.active.\"${TARGET_IP}\".interface" "$INTERFACE"
|
||||||
wild-config-set "cluster.nodes.active.\"${TARGET_IP}\".disk" "$SELECTED_DISK"
|
wild-config-set "cluster.nodes.active.\"${TARGET_IP}\".disk" "$SELECTED_DISK"
|
||||||
wild-config-set "cluster.nodes.active.\"${TARGET_IP}\".control" "true"
|
|
||||||
|
|
||||||
# Copy current Talos version and schematic ID to this node
|
# Copy current Talos version and schematic ID to this node
|
||||||
current_talos_version=$(get_current_config "cluster.nodes.talos.version")
|
current_talos_version=$(get_current_config "cluster.nodes.talos.version")
|
||||||
@@ -331,16 +291,8 @@ if [ "${SKIP_HARDWARE}" = false ]; then
|
|||||||
wild-config-set "cluster.nodes.active.\"${TARGET_IP}\".schematicId" "$current_schematic_id"
|
wild-config-set "cluster.nodes.active.\"${TARGET_IP}\".schematicId" "$current_schematic_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_success "Node $TARGET_IP registered successfully"
|
|
||||||
|
|
||||||
# Generate machine config.
|
|
||||||
print_info "Generating machine configuration for $TARGET_IP..."
|
|
||||||
if wild-cluster-node-machine-config-generate "$TARGET_IP"; then
|
|
||||||
print_success "Machine configuration generated for $TARGET_IP"
|
|
||||||
|
|
||||||
# Ask if user wants to apply the configuration now
|
|
||||||
echo ""
|
echo ""
|
||||||
read -p "Apply configuration to node $TARGET_IP now? (y/N): " -r apply_config
|
read -p "Bring node $TARGET_IP up now? (y/N): " -r apply_config
|
||||||
if [[ $apply_config =~ ^[Yy]$ ]]; then
|
if [[ $apply_config =~ ^[Yy]$ ]]; then
|
||||||
if [ "$DETECTION_IP" != "$TARGET_IP" ]; then
|
if [ "$DETECTION_IP" != "$TARGET_IP" ]; then
|
||||||
# Node is in maintenance mode, use insecure flag
|
# Node is in maintenance mode, use insecure flag
|
||||||
@@ -351,13 +303,44 @@ if [ "${SKIP_HARDWARE}" = false ]; then
|
|||||||
print_info "Applying configuration..."
|
print_info "Applying configuration..."
|
||||||
wild-cluster-node-up "$TARGET_IP"
|
wild-cluster-node-up "$TARGET_IP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Bootstrap the cluster after the first node is up.
|
||||||
|
if [ "$i" -eq 1 ]; then
|
||||||
|
read -p "The cluster should be bootstrapped after the first control node is ready. Is it ready?: " -r is_ready
|
||||||
|
if [[ $is_ready =~ ^[Yy]$ ]]; then
|
||||||
|
print_info "Bootstrapping control plane node $TARGET_IP..."
|
||||||
|
talos config endpoint "$TARGET_IP"
|
||||||
|
|
||||||
|
# Attempt to bootstrap the cluster
|
||||||
|
if talosctl bootstrap --nodes "$TARGET_IP" 2>&1 | tee /tmp/bootstrap_output.log; then
|
||||||
|
print_success "Control plane node $TARGET_IP bootstrapped successfully!"
|
||||||
|
else
|
||||||
|
# Check if the error is because it's already bootstrapped
|
||||||
|
if grep -q "etcd data directory is not empty\|AlreadyExists" /tmp/bootstrap_output.log; then
|
||||||
|
print_info "Cluster is already bootstrapped on $TARGET_IP"
|
||||||
|
else
|
||||||
|
print_error "Failed to bootstrap control plane node $TARGET_IP"
|
||||||
|
print_info "Bootstrap output:"
|
||||||
|
cat /tmp/bootstrap_output.log
|
||||||
|
rm -f /tmp/bootstrap_output.log
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
rm -f /tmp/bootstrap_output.log
|
||||||
|
|
||||||
|
talosctl config endpoint "$vip"
|
||||||
|
print_info "Talos endpoint set to control plane VIP: $vip"
|
||||||
|
|
||||||
|
talosctl kubeconfig "$vip"
|
||||||
|
print_success "Talos kubeconfig updated for control plane VIP: $vip"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
print_info "Configuration not applied. You can apply it later with:"
|
print_info "Configuration not applied. You can apply it later with:"
|
||||||
print_info " wild-cluster-node-up $TARGET_IP --insecure"
|
print_info " wild-cluster-node-up $TARGET_IP --insecure"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
print_warning "Failed to generate machine configuration for $TARGET_IP"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@@ -58,9 +58,6 @@ else
|
|||||||
init_wild_env
|
init_wild_env
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check basic configuration
|
|
||||||
check_basic_config
|
|
||||||
|
|
||||||
# Check cluster configuration
|
# Check cluster configuration
|
||||||
if [ -z "$(get_current_config "cluster.name")" ]; then
|
if [ -z "$(get_current_config "cluster.name")" ]; then
|
||||||
print_error "Cluster configuration is missing"
|
print_error "Cluster configuration is missing"
|
||||||
|
@@ -27,7 +27,16 @@ cd ~
|
|||||||
mkdir ~/my-wild-cloud
|
mkdir ~/my-wild-cloud
|
||||||
cd my-wild-cloud
|
cd my-wild-cloud
|
||||||
|
|
||||||
wild-init
|
wild-setup-scaffold
|
||||||
|
```
|
||||||
|
|
||||||
|
## Download Cluster Node Boot Assets
|
||||||
|
|
||||||
|
We use Talos linux for node operating systems. Run this script to download the OS for use in the rest of the setup.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Generate node boot assets (PXE, iPXE, ISO)
|
||||||
|
wild-cluster-node-boot-assets-download
|
||||||
```
|
```
|
||||||
|
|
||||||
## Dnsmasq
|
## Dnsmasq
|
||||||
@@ -36,54 +45,70 @@ wild-init
|
|||||||
- Ensure it is accessible with ssh.
|
- Ensure it is accessible with ssh.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wild-dnsmasq-install
|
# Install dnsmasq with PXE boot support
|
||||||
|
wild-dnsmasq-install --install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Cluster Setup
|
## Cluster Setup
|
||||||
|
|
||||||
|
### Cluster Infrastructure Setup
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# ONE-TIME CLUSTER INITIALIZATION (run once per cluster)
|
# Configure network, cluster settings, and register nodes
|
||||||
./init-cluster.sh
|
wild-setup-cluster
|
||||||
```
|
```
|
||||||
|
|
||||||
### Join control nodes
|
This interactive script will:
|
||||||
|
- Configure network settings (router IP, DNS, DHCP range)
|
||||||
|
- Configure cluster settings (Talos version, schematic ID, MetalLB pool)
|
||||||
|
- Help you register control plane and worker nodes by detecting their hardware
|
||||||
|
- Generate machine configurations for each node
|
||||||
|
- Apply machine configurations to nodes
|
||||||
|
- Bootstrap the cluster after the first node.
|
||||||
|
|
||||||
Boot each nodes with Talos ISO in maintenance mode.
|
### Install Cluster Services
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./detect-node-hardware.sh <maintenance-ip> <node-number>
|
wild-setup-services
|
||||||
./generate-machine-configs.sh
|
|
||||||
talosctl apply-config --insecure -n 192.168.8.168 --file final/controlplane-node-1.yaml
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Cluster bootstrap
|
## Installing Wild Cloud Apps
|
||||||
|
|
||||||
After all control plane nodes are configured.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Bootstrap the cluster using any control node
|
|
||||||
talosctl bootstrap --nodes 192.168.8.31 --endpoint 192.168.8.31
|
|
||||||
|
|
||||||
# Get kubeconfig
|
|
||||||
talosctl kubeconfig
|
|
||||||
|
|
||||||
# Verify cluster is ready
|
|
||||||
kubectl get nodes
|
|
||||||
```
|
|
||||||
|
|
||||||
### Cluster services
|
|
||||||
|
|
||||||
```bash
|
|
||||||
./setup/cluster/setup-all.sh
|
|
||||||
./setup/cluster/validate-setup.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
## Installing Wild Cloud apps
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# List available applications
|
||||||
wild-apps-list
|
wild-apps-list
|
||||||
wild-app-fetch <app>
|
|
||||||
wild-app-config <app>
|
# Deploy an application
|
||||||
wild-app-deploy <app>
|
wild-app-deploy <app-name>
|
||||||
# Optional: Check in app templates.
|
|
||||||
|
# Check app status
|
||||||
|
wild-app-doctor <app-name>
|
||||||
|
|
||||||
|
# Remove an application
|
||||||
|
wild-app-delete <app-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Individual Node Management
|
||||||
|
|
||||||
|
If you need to manage individual nodes:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Generate patch for a specific node
|
||||||
|
wild-cluster-node-patch-generate <node-ip>
|
||||||
|
|
||||||
|
# Generate final machine config (uses existing patch)
|
||||||
|
wild-cluster-node-machine-config-generate <node-ip>
|
||||||
|
|
||||||
|
# Apply configuration with options
|
||||||
|
wild-cluster-node-up <node-ip> [--insecure] [--skip-patch] [--dry-run]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Asset Management
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Download/cache boot assets (kernel, initramfs, ISO, iPXE)
|
||||||
|
wild-cluster-node-boot-assets-download
|
||||||
|
|
||||||
|
# Install dnsmasq with specific schematic
|
||||||
|
wild-dnsmasq-install --schematic-id <id> --install
|
||||||
```
|
```
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
# - Print functions: print_header, print_info, print_warning, print_success, print_error
|
# - Print functions: print_header, print_info, print_warning, print_success, print_error
|
||||||
# - Config functions: get_current_config, get_current_secret, prompt_with_default
|
# - Config functions: get_current_config, get_current_secret, prompt_with_default
|
||||||
# - Config helpers: prompt_if_unset_config, prompt_if_unset_secret
|
# - Config helpers: prompt_if_unset_config, prompt_if_unset_secret
|
||||||
# - Validation: check_wild_directory, check_basic_config
|
# - Validation: check_wild_directory
|
||||||
# - Utilities: command_exists, file_readable, dir_writable, generate_random_string
|
# - Utilities: command_exists, file_readable, dir_writable, generate_random_string
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
@@ -234,15 +234,6 @@ check_wild_directory() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if basic configuration exists
|
|
||||||
check_basic_config() {
|
|
||||||
if [ -z "$(get_current_config "operator.email")" ]; then
|
|
||||||
print_error "Basic configuration is missing"
|
|
||||||
print_info "Run 'wild-setup-scaffold' first to configure basic settings"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# UTILITY FUNCTIONS
|
# UTILITY FUNCTIONS
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
1
setup/home-scaffold/.gitignore
vendored
1
setup/home-scaffold/.gitignore
vendored
@@ -3,3 +3,4 @@ secrets.yaml
|
|||||||
.bots/*/sessions
|
.bots/*/sessions
|
||||||
backup/
|
backup/
|
||||||
.working
|
.working
|
||||||
|
setup/cluster-nodes/generated/talosconfig
|
||||||
|
Reference in New Issue
Block a user