Adopt existing platform Helm releases before planning
This commit is contained in:
parent
9aeddb1cd6
commit
7dd88385ef
|
|
@ -397,6 +397,21 @@ adopt_tofu_helm_release() {
|
|||
tofu -chdir="${REPO_ROOT}/${stack}" import -input=false "${resource_address}" "${namespace}/${release_name}"
|
||||
}
|
||||
|
||||
untaint_existing_helm_release() {
|
||||
local stack="$1"
|
||||
local resource_address="$2"
|
||||
local state_output
|
||||
|
||||
if ! tofu_state_has_resource "${stack}" "${resource_address}"; then
|
||||
return 0
|
||||
fi
|
||||
state_output="$(tofu -chdir="${REPO_ROOT}/${stack}" state show "${resource_address}")" || return 1
|
||||
if grep -Fq '(tainted)' <<<"${state_output}"; then
|
||||
echo "Clearing stale taint from existing Helm release ${resource_address}..."
|
||||
tofu -chdir="${REPO_ROOT}/${stack}" untaint "${resource_address}"
|
||||
fi
|
||||
}
|
||||
|
||||
adopt_tofu_kubernetes_resource() {
|
||||
local stack="$1"
|
||||
local resource_address="$2"
|
||||
|
|
@ -650,6 +665,7 @@ adopt_platform_existing_resources() {
|
|||
adopt_tofu_helm_release "${stack}" "helm_release.calico_crds" "tigera-operator" "calico-crds"
|
||||
adopt_tofu_helm_release "${stack}" "helm_release.calico" "tigera-operator" "calico"
|
||||
adopt_tofu_helm_release "${stack}" "helm_release.openebs" "openebs" "openebs"
|
||||
adopt_tofu_helm_release "${stack}" "helm_release.metrics_server[\"enabled\"]" "kube-system" "metrics-server"
|
||||
adopt_tofu_helm_release "${stack}" "helm_release.metallb[\"enabled\"]" "metallb-system" "metallb"
|
||||
adopt_tofu_helm_release "${stack}" "helm_release.traefik[\"enabled\"]" "traefik" "traefik"
|
||||
adopt_tofu_helm_release "${stack}" "helm_release.argocd" "argocd" "argocd"
|
||||
|
|
@ -1005,6 +1021,9 @@ run_tofu_stack() {
|
|||
fi
|
||||
done
|
||||
fi
|
||||
if [[ "${stack}" == "bootstrap/platform" ]]; then
|
||||
untaint_existing_helm_release "${stack}" 'helm_release.metrics_server["enabled"]'
|
||||
fi
|
||||
if [[ "${stack}" == "bootstrap/apps" ]] && ! tofu_apply_has_targets "${apply_args[@]}"; then
|
||||
adopt_apps_existing_resources
|
||||
fi
|
||||
|
|
@ -1048,6 +1067,10 @@ run_tofu_plan_stack() {
|
|||
fi
|
||||
|
||||
tofu -chdir="${REPO_ROOT}/${stack}" init
|
||||
if [[ "${stack}" == "bootstrap/platform" ]]; then
|
||||
adopt_platform_existing_resources
|
||||
untaint_existing_helm_release "${stack}" 'helm_release.metrics_server["enabled"]'
|
||||
fi
|
||||
tofu -chdir="${REPO_ROOT}/${stack}" plan "${plan_args[@]}"
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue