Enhance installation scripts to prompt for configuration variables and initialize Wild-Cloud environment

This commit is contained in:
2025-06-29 13:48:53 -07:00
parent 5579e1e3c0
commit dab2551471
11 changed files with 228 additions and 137 deletions

View File

@@ -122,7 +122,8 @@ if [ "$FORCE" = true ] && [ -d "${NODE_SETUP_DIR}/generated" ]; then
fi
cd "${NODE_SETUP_DIR}/generated"
talosctl gen config "$CLUSTER_NAME" "https://$VIP:6443"
talosctl gen secrets
talosctl gen config --with-secrets secrets.yaml "$CLUSTER_NAME" "https://$VIP:6443"
cd - >/dev/null
# Verify generated files

View File

@@ -28,10 +28,9 @@ while [[ $# -gt 0 ]]; do
echo " -h, --help Show this help message"
echo ""
echo "This script will:"
echo " - Configure DNS and SSL certificate settings"
echo " - Configure storage settings (NFS, Docker registry)"
echo " - Generate cluster service configurations"
echo " - Install core services (MetalLB, Traefik, cert-manager, etc.)"
echo " - Each service will prompt for its required configuration"
echo ""
echo "Prerequisites:"
echo " - Run 'wild-setup-scaffold' to initialize the cloud"
@@ -77,134 +76,8 @@ echo ""
print_header "Cluster Services Installation"
# Configure DNS and certificates
if [ -z "$(get_current_config "cluster.certManager.cloudflare.domain")" ]; then
print_header "DNS and Certificate Configuration"
echo "For automatic SSL certificates and DNS management, we use Cloudflare."
echo ""
base_domain=$(get_current_config "cloud.baseDomain")
domain=$(get_current_config "cloud.domain")
echo "Is your domain '${base_domain}' registered and managed through Cloudflare? (y/n)"
read -r use_cloudflare
if [[ "${use_cloudflare}" =~ ^[Yy]$ ]]; then
wild-config-set "cluster.certManager.cloudflare.domain" "${domain}"
current_cf_token=$(get_current_secret "cloudflare.token")
if [ -z "${current_cf_token}" ]; then
echo ""
print_info "You'll need a Cloudflare API token with the following permissions:"
echo " - Zone:Zone:Read"
echo " - Zone:DNS:Edit"
echo " - Include:All zones"
echo ""
echo "Create one at: https://dash.cloudflare.com/profile/api-tokens"
echo ""
fi
cf_token=$(prompt_with_default "Cloudflare API token" "" "${current_cf_token}")
wild-secret-set "cloudflare.token" "${cf_token}"
else
print_warning "You'll need to configure DNS and SSL certificates manually."
print_info "Consider transferring your domain to Cloudflare for easier management."
fi
print_success "DNS and certificate configuration completed"
echo ""
fi
# Configure core network settings
print_header "Network Configuration"
# Get basic domain configuration (should already be set from earlier setup)
domain=$(get_current_config "cloud.domain")
internal_domain=$(get_current_config "cloud.internalDomain")
operator_email=$(get_current_config "operator.email")
if [ -z "$domain" ] || [ -z "$internal_domain" ] || [ -z "$operator_email" ]; then
print_error "Basic domain and operator configuration missing"
print_info "Please run 'wild-setup-scaffold' first to configure basic settings"
exit 1
fi
# Load balancer IP configuration
current_lb_ip=$(get_current_config "cluster.loadBalancerIp")
if [ -z "$current_lb_ip" ] || [ "$current_lb_ip" = "null" ]; then
lb_ip=$(prompt_with_default "Load balancer IP address" "" "${current_lb_ip}")
wild-config-set "cluster.loadBalancerIp" "${lb_ip}"
fi
# IP address pool for MetalLB
current_ip_pool=$(get_current_config "cluster.ipAddressPool")
if [ -z "$current_ip_pool" ] || [ "$current_ip_pool" = "null" ]; then
current_lb_ip=$(get_current_config "cluster.loadBalancerIp")
ip_pool=$(prompt_with_default "IP address pool for load balancer (range)" "${current_lb_ip}-${current_lb_ip}" "${current_ip_pool}")
wild-config-set "cluster.ipAddressPool" "${ip_pool}"
fi
# External DNS resolver for CoreDNS
current_dns_resolver=$(get_current_config "cloud.dns.externalResolver")
if [ -z "$current_dns_resolver" ] || [ "$current_dns_resolver" = "null" ]; then
dns_resolver=$(prompt_with_default "External DNS resolver" "1.1.1.1" "${current_dns_resolver}")
wild-config-set "cloud.dns.externalResolver" "${dns_resolver}"
fi
# ExternalDNS owner ID (unique identifier for DNS records)
current_owner_id=$(get_current_config "cluster.externalDns.ownerId")
if [ -z "$current_owner_id" ] || [ "$current_owner_id" = "null" ]; then
cluster_name=$(get_current_config "cluster.name")
default_owner_id="${cluster_name:-wild-cloud}-$(date +%s)"
owner_id=$(prompt_with_default "ExternalDNS owner ID (unique identifier)" "${default_owner_id}" "${current_owner_id}")
wild-config-set "cluster.externalDns.ownerId" "${owner_id}"
fi
print_success "Network configuration completed"
echo ""
# Configure storage settings
print_header "Storage Configuration"
dns_ip=$(get_current_config "cloud.dns.ip")
internal_domain=$(get_current_config "cloud.internalDomain")
# NFS settings
current_nfs_host=$(get_current_config "cloud.nfs.host")
if [ -z "$current_nfs_host" ] || [ "$current_nfs_host" = "null" ]; then
nfs_host=$(prompt_with_default "NFS server host" "${dns_ip}" "${current_nfs_host}")
wild-config-set "cloud.nfs.host" "${nfs_host}"
fi
current_media_path=$(get_current_config "cloud.nfs.mediaPath")
if [ -z "$current_media_path" ] || [ "$current_media_path" = "null" ]; then
media_path=$(prompt_with_default "NFS media path" "/mnt/storage/media" "${current_media_path}")
wild-config-set "cloud.nfs.mediaPath" "${media_path}"
fi
current_storage_capacity=$(get_current_config "cloud.nfs.storageCapacity")
if [ -z "$current_storage_capacity" ] || [ "$current_storage_capacity" = "null" ]; then
storage_capacity=$(prompt_with_default "Storage capacity for NFS PV" "1Ti" "${current_storage_capacity}")
wild-config-set "cloud.nfs.storageCapacity" "${storage_capacity}"
fi
# Docker Registry settings
current_registry_host=$(get_current_config "cloud.dockerRegistryHost")
if [ -z "$current_registry_host" ] || [ "$current_registry_host" = "null" ]; then
registry_host=$(prompt_with_default "Docker registry hostname" "registry.${internal_domain}" "${current_registry_host}")
wild-config-set "cloud.dockerRegistryHost" "${registry_host}"
fi
current_registry_storage=$(get_current_config "cluster.dockerRegistry.storage")
if [ -z "$current_registry_storage" ] || [ "$current_registry_storage" = "null" ]; then
registry_storage=$(prompt_with_default "Docker registry storage size" "10Gi" "${current_registry_storage}")
wild-config-set "cluster.dockerRegistry.storage" "${registry_storage}"
fi
print_success "Storage configuration completed"
echo ""
print_info "This phase prepares and installs core cluster services (MetalLB, Traefik, cert-manager, etc.)"
print_info "This phase installs core cluster services (MetalLB, Traefik, cert-manager, etc.)"
print_info "Each service will prompt for any required configuration during installation"
print_warning "Make sure your cluster is running and kubectl is configured!"
# Generate cluster services setup files

2
env.sh
View File

@@ -29,3 +29,5 @@ if ! command -v gomplate &> /dev/null; then
echo "Visit: https://docs.gomplate.ca/installing/"
exit 1
fi
echo "Wild-cloud root ready."

View File

@@ -1,5 +1,12 @@
#!/bin/bash
set -e
set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../../bin/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
if [ -z "${WC_HOME}" ]; then
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)"
@@ -9,6 +16,50 @@ fi
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
CERT_MANAGER_DIR="${CLUSTER_SETUP_DIR}/cert-manager"
print_header "Setting up cert-manager"
# Collect required configuration variables
print_info "Collecting cert-manager configuration..."
# Get current values
current_domain=$(get_current_config "cloud.domain")
current_internal_domain=$(get_current_config "cloud.internalDomain")
current_email=$(get_current_config "operator.email")
current_cf_domain=$(get_current_config "cluster.certManager.cloudflare.domain")
current_cf_token=$(get_current_secret "cloudflare.token")
# Prompt for main domain
domain=$(prompt_with_default "Enter main domain name" "example.com" "${current_domain}")
wild-config-set "cloud.domain" "${domain}"
# Prompt for internal domain
internal_domain=$(prompt_with_default "Enter internal domain name" "local.${domain}" "${current_internal_domain}")
wild-config-set "cloud.internalDomain" "${internal_domain}"
# Prompt for operator email
email=$(prompt_with_default "Enter operator email address (for Let's Encrypt)" "" "${current_email}")
wild-config-set "operator.email" "${email}"
# Prompt for Cloudflare domain
cf_domain=$(prompt_with_default "Enter Cloudflare domain (for DNS challenges)" "${domain}" "${current_cf_domain}")
wild-config-set "cluster.certManager.cloudflare.domain" "${cf_domain}"
# Prompt for Cloudflare token
if [ -z "${current_cf_token}" ] || [ "${current_cf_token}" = "null" ]; then
cf_token=$(prompt_with_default "Enter Cloudflare API token (for DNS challenges)" "" "")
else
print_info "Cloudflare token already configured"
read -p "Update Cloudflare API token? (y/N): " update_token
if [[ "${update_token}" =~ ^[Yy]$ ]]; then
cf_token=$(prompt_with_default "Enter new Cloudflare API token" "" "")
else
cf_token="${current_cf_token}"
fi
fi
wild-secret-set "cloudflare.token" "${cf_token}"
print_success "Configuration collected successfully"
# Templates should already be compiled by wild-cluster-services-generate
echo "Using pre-compiled cert-manager templates..."
if [ ! -d "${CERT_MANAGER_DIR}/kustomize" ]; then

View File

@@ -1,5 +1,12 @@
#!/bin/bash
set -e
set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../../bin/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
if [ -z "${WC_HOME}" ]; then
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)"
@@ -9,7 +16,29 @@ fi
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
COREDNS_DIR="${CLUSTER_SETUP_DIR}/coredns"
echo "Setting up CoreDNS for k3s..."
print_header "Setting up CoreDNS for k3s"
# Collect required configuration variables
print_info "Collecting CoreDNS configuration..."
# Get current values
current_internal_domain=$(get_current_config "cloud.internalDomain")
current_lb_ip=$(get_current_config "cluster.loadBalancerIp")
current_external_resolver=$(get_current_config "cloud.dns.externalResolver")
# Prompt for internal domain
internal_domain=$(prompt_with_default "Enter internal domain name" "local.example.com" "${current_internal_domain}")
wild-config-set "cloud.internalDomain" "${internal_domain}"
# Prompt for load balancer IP
lb_ip=$(prompt_with_default "Enter load balancer IP address" "192.168.1.240" "${current_lb_ip}")
wild-config-set "cluster.loadBalancerIp" "${lb_ip}"
# Prompt for external DNS resolver
external_resolver=$(prompt_with_default "Enter external DNS resolver" "8.8.8.8" "${current_external_resolver}")
wild-config-set "cloud.dns.externalResolver" "${external_resolver}"
print_success "Configuration collected successfully"
# Templates should already be compiled by wild-cluster-services-generate
echo "Using pre-compiled CoreDNS templates..."

View File

@@ -1,5 +1,12 @@
#!/bin/bash
set -e
set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../../bin/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
if [ -z "${WC_HOME}" ]; then
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)"
@@ -9,7 +16,24 @@ fi
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
DOCKER_REGISTRY_DIR="${CLUSTER_SETUP_DIR}/docker-registry"
echo "Setting up Docker Registry..."
print_header "Setting up Docker Registry"
# Collect required configuration variables
print_info "Collecting Docker Registry configuration..."
# Get current values
current_registry_host=$(get_current_config "cloud.dockerRegistryHost")
current_storage=$(get_current_config "cluster.dockerRegistry.storage")
# Prompt for Docker Registry host
registry_host=$(prompt_with_default "Enter Docker Registry hostname" "registry.local.example.com" "${current_registry_host}")
wild-config-set "cloud.dockerRegistryHost" "${registry_host}"
# Prompt for storage size
storage=$(prompt_with_default "Enter Docker Registry storage size" "100Gi" "${current_storage}")
wild-config-set "cluster.dockerRegistry.storage" "${storage}"
print_success "Configuration collected successfully"
# Templates should already be compiled by wild-cluster-services-generate
echo "Using pre-compiled Docker Registry templates..."

View File

@@ -1,5 +1,12 @@
#!/bin/bash
set -e
set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../../bin/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
if [ -z "${WC_HOME}" ]; then
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)"
@@ -9,6 +16,20 @@ fi
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
EXTERNALDNS_DIR="${CLUSTER_SETUP_DIR}/externaldns"
print_header "Setting up ExternalDNS"
# Collect required configuration variables
print_info "Collecting ExternalDNS configuration..."
# Get current value
current_owner_id=$(get_current_config "cluster.externalDns.ownerId")
# Prompt for ExternalDNS owner ID
owner_id=$(prompt_with_default "Enter ExternalDNS owner ID (unique identifier for this cluster)" "wild-cloud-$(hostname -s)" "${current_owner_id}")
wild-config-set "cluster.externalDns.ownerId" "${owner_id}"
print_success "Configuration collected successfully"
# Templates should already be compiled by wild-cluster-services-generate
echo "Using pre-compiled ExternalDNS templates..."
if [ ! -d "${EXTERNALDNS_DIR}/kustomize" ]; then

View File

@@ -1,5 +1,12 @@
#!/bin/bash
set -e
set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../../bin/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
if [ -z "${WC_HOME}" ]; then
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)"
@@ -9,7 +16,19 @@ fi
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
KUBERNETES_DASHBOARD_DIR="${CLUSTER_SETUP_DIR}/kubernetes-dashboard"
echo "Setting up Kubernetes Dashboard..."
print_header "Setting up Kubernetes Dashboard"
# Collect required configuration variables
print_info "Collecting Kubernetes Dashboard configuration..."
# Get current value
current_internal_domain=$(get_current_config "cloud.internalDomain")
# Prompt for internal domain
internal_domain=$(prompt_with_default "Enter internal domain name (for dashboard URL)" "local.example.com" "${current_internal_domain}")
wild-config-set "cloud.internalDomain" "${internal_domain}"
print_success "Configuration collected successfully"
# Templates should already be compiled by wild-cluster-services-generate
echo "Using pre-compiled Dashboard templates..."

View File

@@ -1,5 +1,12 @@
#!/bin/bash
set -e
set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../../bin/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
if [ -z "${WC_HOME}" ]; then
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)"
@@ -9,7 +16,24 @@ fi
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
METALLB_DIR="${CLUSTER_SETUP_DIR}/metallb"
echo "Setting up MetalLB..."
print_header "Setting up MetalLB"
# Collect required configuration variables
print_info "Collecting MetalLB configuration..."
# Get current values
current_ip_pool=$(get_current_config "cluster.ipAddressPool")
current_lb_ip=$(get_current_config "cluster.loadBalancerIp")
# Prompt for IP address pool
ip_pool=$(prompt_with_default "Enter IP address pool for MetalLB (CIDR format, e.g., 192.168.1.240-192.168.1.250)" "192.168.1.240-192.168.1.250" "${current_ip_pool}")
wild-config-set "cluster.ipAddressPool" "${ip_pool}"
# Prompt for load balancer IP
lb_ip=$(prompt_with_default "Enter load balancer IP address" "192.168.1.240" "${current_lb_ip}")
wild-config-set "cluster.loadBalancerIp" "${lb_ip}"
print_success "Configuration collected successfully"
# Templates should already be compiled by wild-cluster-services-generate
echo "Using pre-compiled MetalLB templates..."

View File

@@ -2,6 +2,12 @@
set -e
set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../../bin/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
if [ -z "${WC_HOME}" ]; then
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)"
exit 1
@@ -10,7 +16,29 @@ fi
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
NFS_DIR="${CLUSTER_SETUP_DIR}/nfs"
echo "Registering NFS server with Kubernetes cluster..."
print_header "Registering NFS server with Kubernetes cluster"
# Collect required configuration variables
print_info "Collecting NFS configuration..."
# Get current values
current_nfs_host=$(get_current_config "cloud.nfs.host")
current_media_path=$(get_current_config "cloud.nfs.mediaPath")
current_storage_capacity=$(get_current_config "cloud.nfs.storageCapacity")
# Prompt for NFS host
nfs_host=$(prompt_with_default "Enter NFS server hostname or IP address" "192.168.1.100" "${current_nfs_host}")
wild-config-set "cloud.nfs.host" "${nfs_host}"
# Prompt for NFS media path
media_path=$(prompt_with_default "Enter NFS export path for media storage" "/mnt/storage/media" "${current_media_path}")
wild-config-set "cloud.nfs.mediaPath" "${media_path}"
# Prompt for storage capacity
storage_capacity=$(prompt_with_default "Enter NFS storage capacity (e.g., 1Ti, 500Gi)" "1Ti" "${current_storage_capacity}")
wild-config-set "cloud.nfs.storageCapacity" "${storage_capacity}"
print_success "Configuration collected successfully"
# Templates should already be compiled by wild-cluster-services-generate
echo "Using pre-compiled NFS templates..."

View File

@@ -1,5 +1,12 @@
#!/bin/bash
set -e
set -o pipefail
# Source common utilities
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../../bin/wild-common.sh"
# Initialize Wild-Cloud environment
init_wild_env
if [ -z "${WC_HOME}" ]; then
echo "Please source the wildcloud environment first. (e.g., \`source ./env.sh\`)"
@@ -9,7 +16,19 @@ fi
CLUSTER_SETUP_DIR="${WC_HOME}/setup/cluster"
TRAEFIK_DIR="${CLUSTER_SETUP_DIR}/traefik"
echo "Setting up Traefik ingress controller..."
print_header "Setting up Traefik ingress controller"
# Collect required configuration variables
print_info "Collecting Traefik configuration..."
# Get current value
current_lb_ip=$(get_current_config "cluster.loadBalancerIp")
# Prompt for load balancer IP
lb_ip=$(prompt_with_default "Enter load balancer IP address for Traefik" "192.168.1.240" "${current_lb_ip}")
wild-config-set "cluster.loadBalancerIp" "${lb_ip}"
print_success "Configuration collected successfully"
# Install required CRDs first
echo "Installing Gateway API CRDs..."