From 8938cb35117d2658dc361f0182b2cb13cb118aa2 Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Fri, 30 Oct 2026 20:24:21 -0600 Subject: [PATCH] Free worker CPU reservations for Tetragon through Argo CD rollout --- bootstrap/platform/README.md | 15 +++++++++++++++ bootstrap/platform/main.tf | 22 +++++++++++++++++++--- lib/jeannie/pipeline.sh | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/bootstrap/platform/README.md b/bootstrap/platform/README.md index 5efa96a..8bb443e 100644 --- a/bootstrap/platform/README.md +++ b/bootstrap/platform/README.md @@ -41,6 +41,21 @@ attempt is not repeated. Authentication, authorization, configuration, and other errors fail immediately. `LAB_TOFU_K8S_IMPORT_RETRIES` overrides the attempt limit; certificate verification stays enabled throughout. +The Argo CD target also adopts an existing `argocd` Helm release in its configured +namespace when missing from state, after checking the selected control plane. +It preserves release metadata and does not uninstall the release. + +ApplicationSet and the Argo CD server each request 25m CPU, retaining their 300m +limits and existing memory settings. Compared with their previous 100m requests, +this frees 150m on a worker hosting both pods, enough for Tetragon's 125m request +in the observed one-core worker layout. This is a small homelab baseline, not a +guarantee against CPU contention during bursts. Their rolling updates use zero +surge and permit one unavailable replica so a full worker can release the old +reservation before admitting its replacement. A single-replica Argo CD UI or +ApplicationSet controller may be briefly unavailable during its update. +Apply with `LAB_CLUSTER_PROFILE=pimox ./jeannie platform argocd`; the readiness +step waits for the Argo CD rollouts. This does not change worker CPU topology. + ## Monitoring during reduced CPU capacity `platform monitoring` creates the `homelab-monitoring` PriorityClass before diff --git a/bootstrap/platform/main.tf b/bootstrap/platform/main.tf index 98c4a89..ae8c255 100644 --- a/bootstrap/platform/main.tf +++ b/bootstrap/platform/main.tf @@ -1142,9 +1142,17 @@ resource "helm_release" "argocd" { nodeSelector = local.argocd_node_selector affinity = local.argocd_component_affinity.application_set topologySpreadConstraints = local.argocd_component_topology_spread_constraints.application_set + # Release the old reservation first when the single-core worker is full. + deploymentStrategy = { + type = "RollingUpdate" + rollingUpdate = { + maxSurge = 0 + maxUnavailable = 1 + } + } resources = { requests = { - cpu = "100m" + cpu = "25m" memory = "256Mi" } limits = { @@ -1232,9 +1240,17 @@ resource "helm_release" "argocd" { nodeSelector = local.argocd_node_selector affinity = local.argocd_component_affinity.server topologySpreadConstraints = local.argocd_component_topology_spread_constraints.server + # Avoid waiting for spare CPU before replacing the single replica. + deploymentStrategy = { + type = "RollingUpdate" + rollingUpdate = { + maxSurge = 0 + maxUnavailable = 1 + } + } resources = { requests = { - cpu = "100m" + cpu = "25m" memory = "256Mi" } limits = { @@ -1256,7 +1272,7 @@ resource "null_resource" "argocd_ready" { version = var.argocd.version node_selector = jsonencode(local.argocd_node_selector) controller_resource_profile = "10m|1|2Gi" - readiness_check = "9" + readiness_check = "10" } provisioner "local-exec" { diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index cd4fd8a..a27025c 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -611,6 +611,36 @@ adopt_platform_calico_resources() { done } +adopt_platform_argocd_resources() { + local namespace node_exists namespace_exists state_addresses revisions + local expected_node="${LAB_CLUSTER_CONTROL_PLANE_NODE_NAME:-}" + local address="helm_release.argocd" + + if [[ -n "${expected_node}" ]]; then + node_exists="$(kubectl --kubeconfig "${KUBECONFIG_PATH}" --request-timeout=10s \ + get node "${expected_node}" --ignore-not-found -o name)" || return 1 + if [[ -z "${node_exists}" ]]; then + echo "Expected control plane ${expected_node} was not found; refusing Argo CD adoption in this cluster." >&2 + return 1 + fi + fi + namespace="$(printf '%s\n' 'jsonencode(var.argocd.namespace)' | + tofu -chdir="${REPO_ROOT}/bootstrap/platform" console | + python3 -c 'import json,sys; print(json.loads(json.loads(sys.stdin.read())))')" || return 1 + state_addresses="$(platform_read_state_addresses)" || return 1 + if grep -Fxq -- "${address}" <<<"${state_addresses}"; then + return 0 + fi + namespace_exists="$(kubectl --kubeconfig "${KUBECONFIG_PATH}" --request-timeout=10s \ + get namespace "${namespace}" --ignore-not-found -o name)" || return 1 + [[ -n "${namespace_exists}" ]] || return 0 + revisions="$(kubectl --kubeconfig "${KUBECONFIG_PATH}" --request-timeout=10s \ + -n "${namespace}" get secrets -l 'owner=helm,name=argocd' -o name)" || return 1 + [[ -n "${revisions}" ]] || return 0 + echo "Adopting existing Argo CD Helm release ${namespace}/argocd into ${address}" + platform_import_with_retry "${address}" "${namespace}/argocd" || return 1 +} + adopt_platform_existing_resources() { local stack="bootstrap/platform" local dashboard_file @@ -929,6 +959,9 @@ run_tofu_stack() { elif [[ "${target}" == "-target=helm_release.calico_crds" || "${target}" == "-target=helm_release.calico" ]]; then adopt_platform_calico_resources || return 1 break + elif [[ "${target}" == "-target=helm_release.argocd" ]]; then + adopt_platform_argocd_resources || return 1 + break fi done fi