Closed me-marcel closed 1 year ago
Had a look at the module. It seems like v1.4.x defined the load balancer data as follows:
data "hcloud_load_balancer" "traefik" {
count = local.using_klipper_lb ? 0 : var.traefik_enabled == false ? 0 : 1
name = "${var.cluster_name}-traefik"
depends_on = [null_resource.kustomization]
}
The newer module versions >=1.5.x do it as follows:
data "hcloud_load_balancer" "cluster" {
count = local.using_klipper_lb ? 0 : local.ingress_controller == "none" ? 0 : 1
name = var.cluster_name
depends_on = [null_resource.kustomization]
}
That's the reason a migration between the module versions isn't possible. A simple patch would take care of this though:
data "hcloud_load_balancer" "cluster" {
count = local.using_klipper_lb ? 0 : local.ingress_controller == "none" ? 0 : 1
name = local.ingress_controller == "traefik" ? "${var.cluster_name}-traefik" : var.cluster_name
depends_on = [null_resource.kustomization]
}
I'll open a pull request shortly.
@me-marcel Just a quick question: How is the load-balancer of your cluster currently called?
@captnCC The original module version deployed the loadbalancers with the names <cluster>-traefik
and <cluster>-control-plane
. It might be worth mentioning that the option for prefixing the cluster name to the resources was active upon the first deployment which took place like a couple month back already.
I took a quick look in the version history: up to 1.4.8
the load-balancer indeed was called <cluster>-<ingresstype>
.
Starting with 1.5.0
the ingress-type suffix was dropped.
This puts now in a bad situation. For the first part, I don't know if the CCM will change the load-balancer name if it's changed in Kubernetes. (If not, maybe deleting it by hand and letting the CCM recreate could help). But besides that the plan/apply would fail anyway because the data source is invalid and can't resolve to an actual resource.
To allow the upgrade we could introduce a variable to set the load-balancer value manually (back to the old format).
As a last straw the hacky solution: Create a load-balancer on hetzner named kube1
. This way terraform will be satisfied and can continue the upgrade. (This only will impact the output of the cluster ip)
Good thing you were able to confirm it. I may or may not have lost some self-confidence when I came across this behaviour for the first time.
Of course this ain't nice but I am confident that we will be able to find a proper solution for this which is not hacky and does not involve creating additional resources for the sake of making the migration work, because I suspect that my case may not be the only one.
I actually like your suggestion of having a way to override the name since I did take a similar approach in the pull request I opened in regards to this issue (see: https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/pull/490). Ofc. this is strongly tailored to the needs I had so there might also be a more general way of approaching this. I'd definately be happy to see such an option in the future.
FYI: I did take the changes of the pull request and applied them in a local version of the module which I referenced for now so I was able to upgrade the respective modules. The cluster's still up and all of the resulting changes were applied successfully. So there is no pressure of fixing this within the repo but it'll be nice to see such an option in the future to allow for backwards-compatibility.
Replied in the PR.
Description Upgrading the Module from v1.4.x to >=v1.5.x fails.
Error
Environment
Reproduction
terraform plan
- It's important that your Terraform state contains an applied configuration using the module <=v1.4.xWorkaround
${var.cluster_name}-control-plane
- This may cause issues although it makes the plan workIt'd be great if we were able to find a permanently viable solution for this.