Fix wild-setup-cluster: continue if secrets already generated; fix talos context detection command.
This commit is contained in:
@@ -60,15 +60,16 @@ print_header "Talos Cluster Configuration Generation"
|
||||
|
||||
# Ensure required directories exist
|
||||
NODE_SETUP_DIR="${WC_HOME}/setup/cluster-nodes"
|
||||
mkdir -p "${NODE_SETUP_DIR}/generated"
|
||||
|
||||
# Generate cluster secrets
|
||||
|
||||
if [ -f "${NODE_SETUP_DIR}/generated/secrets.yaml" ] && [ "$FORCE" = false ]; then
|
||||
print_success "Cluster secrets already exists in ${NODE_SETUP_DIR}/generated/"
|
||||
# Check if generated directory already exists and has content
|
||||
if [ -d "${NODE_SETUP_DIR}/generated" ] && [ "$(ls -A "${NODE_SETUP_DIR}/generated" 2>/dev/null)" ] && [ "$FORCE" = false ]; then
|
||||
print_success "Cluster configuration already exists in ${NODE_SETUP_DIR}/generated/"
|
||||
print_info "Skipping cluster configuration generation"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir -p "${NODE_SETUP_DIR}/generated"
|
||||
|
||||
# Prepare directory for generated secrets
|
||||
print_info "Generating new cluster secrets..."
|
||||
if [ -d "${NODE_SETUP_DIR}/generated" ]; then
|
||||
|
@@ -7,7 +7,6 @@ set -o pipefail
|
||||
|
||||
SKIP_INSTALLER=false
|
||||
SKIP_HARDWARE=false
|
||||
SKIP_CONFIGS=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
@@ -19,10 +18,6 @@ while [[ $# -gt 0 ]]; do
|
||||
SKIP_HARDWARE=true
|
||||
shift
|
||||
;;
|
||||
--skip-configs)
|
||||
SKIP_CONFIGS=true
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: $0 [phase-options]"
|
||||
echo ""
|
||||
@@ -72,16 +67,20 @@ echo ""
|
||||
|
||||
# Generate initial cluster configuration
|
||||
|
||||
wild-cluster-config-generate
|
||||
if ! wild-cluster-config-generate; then
|
||||
print_error "Failed to generate cluster configuration"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Configure Talos cli with our new cluster context
|
||||
|
||||
HAS_CONTEXT=$(talos config get | grep -c "<cluster.name>")
|
||||
CLUSTER_NAME=$(wild-config "cluster.name")
|
||||
HAS_CONTEXT=$(talosctl config contexts | grep -c "$CLUSTER_NAME" || true)
|
||||
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"
|
||||
print_info "No Talos context found for cluster $CLUSTER_NAME, creating..."
|
||||
talosctl config merge ${WC_HOME}/setup/cluster-nodes/generated/talosconfig
|
||||
talosctl config use "$CLUSTER_NAME"
|
||||
print_success "Talos context for $CLUSTER_NAME created and set as current"
|
||||
fi
|
||||
|
||||
# Talos asset download
|
||||
@@ -102,7 +101,7 @@ fi
|
||||
# Configuration
|
||||
# =============================================================================
|
||||
|
||||
prompt_if_unset_config "owner.email" "Owner email address"
|
||||
prompt_if_unset_config "operator.email" "Operator email address"
|
||||
|
||||
# Configure network settings
|
||||
CURRENT_IP=$(ip route get 8.8.8.8 | awk '{print $7; exit}' 2>/dev/null || echo "192.168.1.100")
|
||||
@@ -427,7 +426,7 @@ if [ "${SKIP_HARDWARE}" = false ]; then
|
||||
|
||||
# Generate machine config immediately
|
||||
print_info "Generating machine configuration for $WORKER_IP..."
|
||||
if wild-cluster-node-machine-config-generate "$WORKER_IP"; then
|
||||
if wild-cluster-node-patch-generate "$WORKER_IP"; then
|
||||
print_success "Machine configuration generated for $WORKER_IP"
|
||||
|
||||
# Ask if user wants to apply the configuration now
|
||||
|
Reference in New Issue
Block a user