Files

66 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
source .env
export PROXMOX_VE_USERNAME=${PROXMOX_VE_USERNAME}
export PROXMOX_VE_PASSWORD=${PROXMOX_VE_PASSWORD}
confirm() {
local message="$1"
read -p "$message (y/n): " response
[[ "$response" == "y" ]]
}
check_dependencies() {
local missing_tools=()
for tool in terraform helm kubectl; do
if ! command -v "$tool" &> /dev/null; then
missing_tools+=("$tool")
fi
done
if [ ${#missing_tools[@]} -ne 0 ]; then
echo "Error: Missing required tools: ${missing_tools[*]}"
echo "Please install the following tools before running this script:"
for tool in "${missing_tools[@]}"; do
echo " - $tool"
done
exit 1
fi
echo "All required tools are available"
}
check_dependencies
tfplan=$(terraform plan -out=tfplan)
echo "$tfplan"
if confirm "Apply?"; then
terraform apply tfplan
fi
if confirm "Save kubeconfig?"; then
terraform output -raw kubeconfig > ~/.kube/${TALOS_CLUSTER_NAME}.yaml
fi
if confirm "Install Cilium?"; then
helm repo add cilium https://helm.cilium.io/
helm repo update
helm upgrade \
--kubeconfig ~/.kube/${TALOS_CLUSTER_NAME}.yaml \
--install \
cilium \
cilium/cilium \
--namespace kube-system \
--values cilium/values.yaml \
--set cluster.name=${TALOS_CLUSTER_NAME} \
--set cluster.id=1
fi
if confirm "Apply Cilium IP Pool and L2 Announcement Policy?"; then
kubectl apply --kubeconfig ~/.kube/${TALOS_CLUSTER_NAME}.yaml -f cilium/ippool.yaml
kubectl apply --kubeconfig ~/.kube/${TALOS_CLUSTER_NAME}.yaml -f cilium/l2-announcement-policy.yaml
fi