This commit is contained in:
root
2026-02-27 17:12:39 +00:00
parent 954331550d
commit 3d5038b25d
3 changed files with 1244 additions and 1229 deletions

View File

@@ -206,7 +206,7 @@ resource "null_resource" "wait_for_cp1_api" {
provisioner "local-exec" { provisioner "local-exec" {
interpreter = ["/bin/bash", "-lc"] interpreter = ["/bin/bash", "-lc"]
environment = { environment = {
CP1_IP = "control-plane1.undercloud.local" # <-- set this CP1 = "control-plane1.undercloud.local" # <-- set this
} }
command = <<EOF command = <<EOF
@@ -215,7 +215,7 @@ set -euo pipefail
deadline=$((SECONDS + 1800)) # 30 min deadline=$((SECONDS + 1800)) # 30 min
echo "Waiting for Kubernetes API on $CP1_IP:6443 ..." echo "Waiting for Kubernetes API on $CP1_IP:6443 ..."
until curl -kfsS "https://$CP1_IP:6443/healthz" | grep -qx "ok"; do until curl -kfsS "https://$CP1:6443/healthz" | grep -qx "ok"; do
if [ $SECONDS -ge $deadline ]; then if [ $SECONDS -ge $deadline ]; then
echo "Timeout waiting for API server" echo "Timeout waiting for API server"
exit 1 exit 1
@@ -237,8 +237,8 @@ resource "null_resource" "wait_for_cp2_cp3_api" {
provisioner "local-exec" { provisioner "local-exec" {
interpreter = ["/bin/bash", "-lc"] interpreter = ["/bin/bash", "-lc"]
environment = { environment = {
CP2_IP = "control-plane2.undercloud.local" # set this CP2 = "control-plane2.undercloud.local" # set this
CP3_IP = "control-plane3.undercloud.local" # set this CP3 = "control-plane3.undercloud.local" # set this
} }
command = <<EOF command = <<EOF
@@ -252,14 +252,14 @@ check() {
} }
echo "Waiting for cp2 API..." echo "Waiting for cp2 API..."
until check "$CP2_IP"; do until check "$CP2"; do
if [ $SECONDS -ge $deadline ]; then echo "Timeout waiting for cp2 API"; exit 1; fi if [ $SECONDS -ge $deadline ]; then echo "Timeout waiting for cp2 API"; exit 1; fi
sleep 5 sleep 5
done done
echo "cp2 API is up." echo "cp2 API is up."
echo "Waiting for cp3 API..." echo "Waiting for cp3 API..."
until check "$CP3_IP"; do until check "$CP3"; do
if [ $SECONDS -ge $deadline ]; then echo "Timeout waiting for cp3 API"; exit 1; fi if [ $SECONDS -ge $deadline ]; then echo "Timeout waiting for cp3 API"; exit 1; fi
sleep 5 sleep 5
done done
@@ -268,6 +268,35 @@ EOF
} }
} }
resource "null_resource" "wait_for_cluster_ready" {
depends_on = [
null_resource.wait_for_cp1_api,
null_resource.wait_for_cp2_cp3_api,
]
provisioner "local-exec" {
interpreter = ["/bin/bash", "-lc"]
environment = {
CP1_HOST = "control-plane1.undercloud.local"
}
command = <<EOF
set -euo pipefail
deadline=$((SECONDS + 1800))
echo "Waiting for cluster readiness on $CP1_HOST (/readyz) ..."
until curl -kfsS "https://$CP1_HOST:6443/readyz" | grep -qx "ok"; do
if [ $SECONDS -ge $deadline ]; then
echo "Timeout waiting for /readyz"
exit 1
fi
sleep 5
done
echo "Cluster API reports ready."
EOF
}
}
# =============== deploy Control Plane ==================== # =============== deploy Control Plane ====================
resource "proxmox_virtual_environment_vm" "control_plane1" { resource "proxmox_virtual_environment_vm" "control_plane1" {
@@ -311,13 +340,6 @@ resource "proxmox_virtual_environment_vm" "control_plane1" {
user_data_file_id = "${proxmox_virtual_environment_file.control_plane1_ignition.id}" user_data_file_id = "${proxmox_virtual_environment_file.control_plane1_ignition.id}"
} }
} }
resource "null_resource" "wait_for_cp1" {
depends_on = [proxmox_virtual_environment_vm.control_plane1]
provisioner "local-exec" {
command = "sleep 240" # Warte 4 Minuten
}
}
resource "proxmox_virtual_environment_vm" "control_plane2" { resource "proxmox_virtual_environment_vm" "control_plane2" {
name = "control-plane2" name = "control-plane2"
@@ -405,13 +427,6 @@ resource "proxmox_virtual_environment_vm" "control_plane3" {
user_data_file_id = "${proxmox_virtual_environment_file.control_plane3_ignition.id}" user_data_file_id = "${proxmox_virtual_environment_file.control_plane3_ignition.id}"
} }
} }
resource "null_resource" "wait_for_cp3" {
depends_on = [proxmox_virtual_environment_vm.control_plane3]
provisioner "local-exec" {
command = "sleep 300" # Warte 4 Minuten
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long