Start existing cluster during up when stopped

This commit is contained in:
juvdiaz 2026-06-29 12:38:13 -06:00
parent 3c24f05ff6
commit b763e8c747
3 changed files with 50 additions and 0 deletions

View File

@ -237,6 +237,11 @@ running the full pipeline:
./jeannie fix-debian-docker-root
```
When `./jeannie up` sees an existing tracked kubeadm control plane but
the Kubernetes API is down, it starts the saved runtime before applying cluster
changes. Use `./jeannie rebuild-cluster` only when you intentionally
want to destroy and recreate the cluster.
## Validation
Useful checks after a rebuild:

View File

@ -237,6 +237,11 @@ running the full pipeline:
./{{ main_script }} fix-debian-docker-root
```
When `./{{ main_script }} up` sees an existing tracked kubeadm control plane but
the Kubernetes API is down, it starts the saved runtime before applying cluster
changes. Use `./{{ main_script }} rebuild-cluster` only when you intentionally
want to destroy and recreate the cluster.
## Validation
Useful checks after a rebuild:

40
jeannie
View File

@ -3789,6 +3789,7 @@ up() {
if [[ -z "${LAB_CLUSTER_VAR_FILE:-}" ]]; then
prepare_cluster_worker_var_file true
fi
ensure_existing_cluster_started_for_up
run_tofu_stack "bootstrap/cluster"
doctor_versions_report
run_tofu_stack "bootstrap/platform"
@ -4006,6 +4007,45 @@ start_cluster() {
echo "Kubernetes runtime start requested. Use 'kubectl get nodes -o wide' to watch readiness."
}
kubernetes_api_reachable() {
kubectl --kubeconfig "${KUBECONFIG_PATH}" get --raw=/readyz >/dev/null 2>&1
}
cluster_control_plane_tracked() {
tofu_state_has_resource "bootstrap/cluster" "null_resource.kubeadm_control_plane"
}
wait_for_kubernetes_api() {
local timeout_seconds="${1:-180}"
local elapsed=0
until kubernetes_api_reachable; do
if ((elapsed >= timeout_seconds)); then
echo "Kubernetes API did not become reachable after ${timeout_seconds}s." >&2
return 1
fi
sleep 5
elapsed=$((elapsed + 5))
done
}
ensure_existing_cluster_started_for_up() {
if ! cluster_control_plane_tracked; then
echo "No tracked kubeadm control plane found; bootstrap/cluster will create one."
return 0
fi
if kubernetes_api_reachable; then
echo "Existing Kubernetes control plane is reachable."
return 0
fi
echo "Existing Kubernetes control plane is tracked but API is down; starting cluster runtime..."
start_cluster
wait_for_kubernetes_api "${LAB_CLUSTER_START_WAIT_SECONDS:-180}"
echo "Existing Kubernetes control plane is reachable after start."
}
status_section() {
printf '\n== %s ==\n' "$1"
}