Moves setup files into embedded package.
This commit is contained in:
80
internal/setup/cluster-nodes/init-cluster.sh
Executable file
80
internal/setup/cluster-nodes/init-cluster.sh
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Talos cluster initialization script
|
||||
# This script performs one-time cluster setup: generates secrets, base configs, and sets up talosctl
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Check if WC_HOME is set
|
||||
if [ -z "${WC_HOME:-}" ]; then
|
||||
echo "Error: WC_HOME environment variable not set. Run \`source ./env.sh\`."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NODE_SETUP_DIR="${WC_HOME}/setup/cluster-nodes"
|
||||
|
||||
# Get cluster configuration from config.yaml
|
||||
CLUSTER_NAME=$(wild-config cluster.name)
|
||||
VIP=$(wild-config cluster.nodes.control.vip)
|
||||
TALOS_VERSION=$(wild-config cluster.nodes.talos.version)
|
||||
|
||||
echo "Initializing Talos cluster: $CLUSTER_NAME"
|
||||
echo "VIP: $VIP"
|
||||
echo "Talos version: $TALOS_VERSION"
|
||||
|
||||
# Create directories
|
||||
mkdir -p generated final patch
|
||||
|
||||
# Check if cluster secrets already exist
|
||||
if [ -f "generated/secrets.yaml" ]; then
|
||||
echo ""
|
||||
echo "⚠️ Cluster secrets already exist!"
|
||||
echo "This will regenerate ALL cluster certificates and invalidate existing nodes."
|
||||
echo ""
|
||||
read -p "Do you want to continue? (y/N): " -r
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Cancelled."
|
||||
exit 0
|
||||
fi
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Generate fresh cluster secrets
|
||||
echo "Generating cluster secrets..."
|
||||
cd generated
|
||||
talosctl gen secrets -o secrets.yaml --force
|
||||
|
||||
echo "Generating base machine configs..."
|
||||
talosctl gen config --with-secrets secrets.yaml "$CLUSTER_NAME" "https://$VIP:6443" --force
|
||||
cd ..
|
||||
|
||||
# Setup talosctl context
|
||||
echo "Setting up talosctl context..."
|
||||
|
||||
# Remove existing context if it exists
|
||||
talosctl config context "$CLUSTER_NAME" --remove 2>/dev/null || true
|
||||
|
||||
# Merge new configuration
|
||||
talosctl config merge ./generated/talosconfig
|
||||
talosctl config endpoint "$VIP"
|
||||
|
||||
echo ""
|
||||
echo "✅ Cluster initialization complete!"
|
||||
echo ""
|
||||
echo "Cluster details:"
|
||||
echo " - Name: $CLUSTER_NAME"
|
||||
echo " - VIP: $VIP"
|
||||
echo " - Secrets: generated/secrets.yaml"
|
||||
echo " - Base configs: generated/controlplane.yaml, generated/worker.yaml"
|
||||
echo ""
|
||||
echo "Talosctl context configured:"
|
||||
talosctl config info
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "1. Register nodes with hardware detection:"
|
||||
echo " ./detect-node-hardware.sh <maintenance-ip> <node-number>"
|
||||
echo ""
|
||||
echo "2. Generate machine configurations:"
|
||||
echo " ./generate-machine-configs.sh"
|
||||
echo ""
|
||||
echo "3. Apply configurations to nodes"
|
||||
@@ -0,0 +1,23 @@
|
||||
machine:
|
||||
install:
|
||||
disk: {{ index .cluster.nodes.active "{{NODE_NAME}}" "disk" }}
|
||||
image: factory.talos.dev/metal-installer/{{SCHEMATIC_ID}}:{{VERSION}}
|
||||
network:
|
||||
hostname: "{{NODE_NAME}}"
|
||||
interfaces:
|
||||
- interface: {{ index .cluster.nodes.active "{{NODE_NAME}}" "interface" }}
|
||||
dhcp: false
|
||||
addresses:
|
||||
- "{{NODE_IP}}/24"
|
||||
routes:
|
||||
- network: 0.0.0.0/0
|
||||
gateway: {{ .cloud.router.ip }}
|
||||
vip:
|
||||
ip: {{ .cluster.nodes.control.vip }}
|
||||
# cluster:
|
||||
# discovery:
|
||||
# enabled: true
|
||||
# registries:
|
||||
# service:
|
||||
# disabled: true
|
||||
# allowSchedulingOnControlPlanes: true
|
||||
23
internal/setup/cluster-nodes/patch.templates/worker.yaml
Normal file
23
internal/setup/cluster-nodes/patch.templates/worker.yaml
Normal file
@@ -0,0 +1,23 @@
|
||||
machine:
|
||||
install:
|
||||
disk: {{ index .cluster.nodes.active "{{NODE_NAME}}" "disk" }}
|
||||
image: factory.talos.dev/metal-installer/{{ .cluster.nodes.talos.schematicId}}:{{ .cluster.nodes.talos.version}}
|
||||
network:
|
||||
hostname: "{{NODE_NAME}}"
|
||||
interfaces:
|
||||
- interface: {{ index .cluster.nodes.active "{{NODE_NAME}}" "interface" }}
|
||||
dhcp: true
|
||||
addresses:
|
||||
- "{{NODE_IP}}/24"
|
||||
routes:
|
||||
- network: 0.0.0.0/0
|
||||
gateway: {{ .cloud.router.ip }}
|
||||
kubelet:
|
||||
extraMounts:
|
||||
- destination: /var/lib/longhorn
|
||||
type: bind
|
||||
source: /var/lib/longhorn
|
||||
options:
|
||||
- bind
|
||||
- rshared
|
||||
- rw
|
||||
63
internal/setup/cluster-nodes/talos-schemas.yaml
Normal file
63
internal/setup/cluster-nodes/talos-schemas.yaml
Normal file
@@ -0,0 +1,63 @@
|
||||
# Talos Version to Schematic ID Mappings
|
||||
#
|
||||
# This file contains mappings of Talos versions to their corresponding
|
||||
# default schematic IDs for wild-cloud deployments.
|
||||
#
|
||||
# Schematic IDs are generated from factory.talos.dev and include
|
||||
# common system extensions needed for typical hardware.
|
||||
#
|
||||
# To add new versions:
|
||||
# 1. Go to https://factory.talos.dev/
|
||||
# 2. Select the system extensions you need
|
||||
# 3. Generate the schematic
|
||||
# 4. Add the version and schematic ID below
|
||||
|
||||
# Format: Each schematic ID is the primary key with version and definition nested
|
||||
"434a0300db532066f1098e05ac068159371d00f0aba0a3103a0e826e83825c82":
|
||||
schematic:
|
||||
customization:
|
||||
systemExtensions:
|
||||
officialExtensions:
|
||||
- siderolabs/gvisor
|
||||
- siderolabs/intel-ucode
|
||||
- siderolabs/iscsi-tools
|
||||
- siderolabs/util-linux-tools
|
||||
"f309e674d9ad94655e2cf8a43ea1432475c717cd1885f596bd7ec852b900bc5b":
|
||||
schematic:
|
||||
customization:
|
||||
systemExtensions:
|
||||
officialExtensions:
|
||||
- siderolabs/gvisor
|
||||
- siderolabs/intel-ucode
|
||||
- siderolabs/iscsi-tools
|
||||
- siderolabs/nvidia-container-toolkit-lts
|
||||
- siderolabs/nvidia-container-toolkit-production
|
||||
- siderolabs/nvidia-fabricmanager-lts
|
||||
- siderolabs/nvidia-fabricmanager-production
|
||||
- siderolabs/nvidia-open-gpu-kernel-modules-lts
|
||||
- siderolabs/nvidia-open-gpu-kernel-modules-production
|
||||
- siderolabs/util-linux-tools"
|
||||
"56774e0894c8a3a3a9834a2aea65f24163cacf9506abbcbdc3ba135eaca4953f":
|
||||
schematic:
|
||||
customization:
|
||||
systemExtensions:
|
||||
officialExtensions:
|
||||
- siderolabs/gvisor
|
||||
- siderolabs/intel-ucode
|
||||
- siderolabs/iscsi-tools
|
||||
- siderolabs/nvidia-container-toolkit-production
|
||||
- siderolabs/nvidia-fabricmanager-production
|
||||
- siderolabs/nvidia-open-gpu-kernel-modules-production
|
||||
- siderolabs/util-linux-tools
|
||||
"9ac1424dbdf4b964154a36780dbf2215bf17d2752cd0847fa3b81d7da761457f":
|
||||
schematic:
|
||||
customization:
|
||||
systemExtensions:
|
||||
officialExtensions:
|
||||
- siderolabs/gvisor
|
||||
- siderolabs/intel-ucode
|
||||
- siderolabs/iscsi-tools
|
||||
- siderolabs/nonfree-kmod-nvidia-production
|
||||
- siderolabs/nvidia-container-toolkit-production
|
||||
- siderolabs/nvidia-fabricmanager-production
|
||||
- siderolabs/util-linux-tools
|
||||
Reference in New Issue
Block a user