Update multiplane.sh
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
CONFIG_FILE="${1:-config.yaml}"
|
||||
CONFIG_FILE="${1:-config-test.yaml}"
|
||||
|
||||
if [[ "$EUID" -ne 0 ]]; then
|
||||
echo -e "\e[31m[FATAL]\e[39m Currently this script requires being ran as root user - please try again as root."
|
||||
@@ -81,17 +81,42 @@ get_ipv4_address() {
|
||||
done
|
||||
}
|
||||
|
||||
yq -i -oy ".k0s.hostname = \"$(gum input --placeholder "Cluster Domain:" --prompt "* " --width 80 --value "$(yq '.k0s.hostname' $CONFIG_FILE)")\"" "$CONFIG_FILE"
|
||||
yq -i -oy ".k0s.private_ip_range = \"$(gum input --placeholder "Node IP Range::" --prompt "* " --width 80 --value "$(yq '.k0s.private_ip_range' $CONFIG_FILE)")\"" "$CONFIG_FILE"
|
||||
clear; echo "Enter a cluster hostname. (e.g., cluster.local)";
|
||||
yq -i -oy ".k0s.hostname = \"$(gum input --placeholder "cluster.local" --prompt "* " --width 80 --value "$(yq '.k0s.hostname' $CONFIG_FILE)")\"" "$CONFIG_FILE"
|
||||
|
||||
clear; echo "Enter a cluster IP subnet. (e.g., 10.1.0.0/24)";
|
||||
yq -i -oy ".k0s.private_ip_range = \"$(gum input --placeholder "10.1.0.0/24" --prompt "* " --width 80 --value "$(yq '.k0s.private_ip_range' $CONFIG_FILE)")\"" "$CONFIG_FILE"
|
||||
|
||||
clear; echo "Enter a public IP subnet. (e.g., 192.168.0.0/24)";
|
||||
yq -i -oy ".metallb.public_ip_range = \"$(gum input --placeholder "192.168.0.0/24" --prompt "* " --width 80 --value "$(yq '.metallb.public_ip_range' $CONFIG_FILE)")\"" "$CONFIG_FILE"
|
||||
|
||||
# Initialize array to store entries
|
||||
declare -a entries
|
||||
|
||||
# Proxy node entry (2 nodes required)
|
||||
clear; gum style --border double --padding "1 2" --border-foreground 212 "Proxy Configuration (2 Required)"; sleep 3
|
||||
|
||||
for i in 1 2; do
|
||||
clear; gum style --border double --padding "1 2" --border-foreground 212 "Proxy Node $i/2"
|
||||
|
||||
# Get MAC address
|
||||
mac=$(get_mac_address)
|
||||
|
||||
# Get IPv4 address
|
||||
ip=$(get_ipv4_address)
|
||||
|
||||
# Add entry using yq
|
||||
yq -i -oy ".haproxy.proxy.$i = {\"mac\": \"$mac\", \"ip\": \"$ip\"}" "$CONFIG_FILE"
|
||||
done
|
||||
|
||||
clear; echo "HAProxy Kuberenetes VIP. (e.g., 10.1.0.10)";
|
||||
yq -i -oy ".haproxy.kube.vip = \"$(gum input --placeholder "10.1.0.10" --prompt "* " --width 80 --value "$(yq '.haproxy.kube.vip' $CONFIG_FILE)")\"" "$CONFIG_FILE"
|
||||
|
||||
# Controller node entry (3 nodes required)
|
||||
gum style --border double --padding "1 2" --border-foreground 212 "Controller Node Configuration (3 Required)"
|
||||
clear; gum style --border double --padding "1 2" --border-foreground 212 "Controller Node Configuration (3 Required)"; sleep 3
|
||||
|
||||
for i in 1 2 3; do
|
||||
gum style --border double --padding "1 2" --border-foreground 212 "Controller Node $i/3"
|
||||
clear; gum style --border double --padding "1 2" --border-foreground 212 "Controller Node $i/3"
|
||||
|
||||
# Get MAC address
|
||||
mac=$(get_mac_address)
|
||||
@@ -104,12 +129,12 @@ for i in 1 2 3; do
|
||||
done
|
||||
|
||||
# Controller node entry (3 nodes required)
|
||||
gum style --border double --padding "1 2" --border-foreground 212 "Worker Node Configuration (2 Required)"
|
||||
gum style --border double --padding "1 2" --border-foreground 212 "Worker Node Configuration (2 Required)"; sleep 3
|
||||
|
||||
# Add worker node loop
|
||||
count=0
|
||||
while [ $count -lt 250 ]; do
|
||||
gum style --border double --padding "1 2" --border-foreground 212 "Worker Node Entry ($(($count + 1))/250)"
|
||||
clear; gum style --border double --padding "1 2" --border-foreground 212 "Worker Node Entry ($(($count + 1))/250)"
|
||||
|
||||
# Get MAC address
|
||||
mac=$(get_mac_address)
|
||||
@@ -123,11 +148,11 @@ while [ $count -lt 250 ]; do
|
||||
|
||||
# Ask to continue
|
||||
if [ $count -lt 250 ]; then
|
||||
gum confirm "Add another worker node?" || break
|
||||
clear; gum confirm "Add another worker node?" || break
|
||||
fi
|
||||
done
|
||||
|
||||
# Display results
|
||||
if [ $count -gt 0 ]; then
|
||||
gum style --border double --padding "1 2" --border-foreground 212 "✓ Configuration saved to $CONFIG_FILE"
|
||||
clear; gum style --border double --padding "1 2" --border-foreground 212 "✓ Configuration saved to $CONFIG_FILE"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user