kube-hetzner / terraform-hcloud-kube-hetzner

Optimized and Maintenance-free Kubernetes on Hetzner Cloud in one command!
MIT License
2.42k stars 371 forks source link

Load Balancer would be newly created #1443

Closed dissy123 closed 3 months ago

dissy123 commented 3 months ago

Description

When i run terraform plan the Hetzner Load Balancer will always be recreated. But that's not good because many DNS Entries are directed to that IP Adress

I also checked with the terraform.tfstate file but all values are the same :/

Kube.tf file

locals {
  hcloud_token = "*"
}

module "kube-hetzner" {
  providers = {
    hcloud = hcloud
  }
  hcloud_token = var.hcloud_token != "" ? var.hcloud_token : local.hcloud_token

  source = "kube-hetzner/kube-hetzner/hcloud"

  ssh_public_key = file("")
  ssh_private_key = file("")

  hcloud_ssh_key_id = "*"

  network_region = "eu-central" # change to `us-east` if location is ash

  control_plane_nodepools = [
    {
      name        = "control1-plane-fsn1",
      server_type = "cax11",
      location    = "fsn1",
      labels      = [],
      taints      = [],
      count       = 1,

      # Enable automatic backups via Hetzner (default: false)
      backups = true
    },
    {
      name        = "control2-plane-fsn1",
      server_type = "cax11",
      location    = "fsn1",
      labels      = [],
      taints      = [],
      count       = 1,

      # Enable automatic backups via Hetzner (default: false)
      backups = true
    },
    {
      name        = "control3-plane-fsn1",
      server_type = "cax11",
      location    = "fsn1",
      labels      = [],
      taints      = [],
      count       = 1,

      # Enable automatic backups via Hetzner (default: false)
      backups = true
    }
  ]

  agent_nodepools = [
    {
      name        = "agent1",
      server_type = "cax21",
      location    = "fsn1",
      labels      = ["arm"],
      taints      = [],
      count       = 1,

      # Enable automatic backups via Hetzner (default: false)
      backups = true
    },
    {
      name        = "agent2",
      server_type = "cax21",
      location    = "fsn1",
      labels      = ["arm"],
      taints      = [],
      count       = 1,

      # Enable automatic backups via Hetzner (default: false)
      backups = true
    },
    {
      name        = "agent3",
      server_type = "cx41",
      location    = "fsn1",
      labels      = ["amd"],
      taints      = [],
      count       = 1,

      # Enable automatic backups via Hetzner (default: false)
      backups = true
    },

  # * LB location and type, the latter will depend on how much load you want it to handle, see https://www.hetzner.com/cloud/load-balancer
  load_balancer_type     = "lb11"
  load_balancer_location = "eu-central"

  enable_delete_protection = {
     floating_ip   = true
     load_balancer = true
     volume        = true
  }

  autoscaler_nodepools = [
     {
       name        = "autoscaled-small"
       server_type = "cax21"
       location    = "fsn1"
       min_nodes   = 1
       max_nodes   = 5
     }
  ]

  ingress_controller = "nginx"

  cluster_name = "*"

  extra_firewall_rules = [
    {
      "description": "Allow Outbound UDP NTP Requests",
      "destination_ips": ["0.0.0.0/0", "::/0"],
      "direction": "out",
      "port": "123",
      "protocol": "udp",
      "source_ips": []
    },
    {
      "description": "Allow Incoming ICMP Ping Requests",
      "destination_ips": [],
      "direction": "in",
      "port": "",
      "protocol": "icmp",
      "source_ips": ["0.0.0.0/0", "::/0"]
    },
    {
      "description": "Allow Outbound ICMP Ping Requests",
      "destination_ips": ["0.0.0.0/0", "::/0"],
      "direction": "out",
      "port": "",
      "protocol": "icmp",
      "source_ips": []
    },
    {
      "description": "Allow Outbound HTTPS Requests",
      "destination_ips": ["0.0.0.0/0", "::/0"],
      "direction": "out",
      "port": "443",
      "protocol": "tcp",
      "source_ips": []
    }
  ]

  enable_cert_manager = true

  lb_hostname = ""

}

provider "hcloud" {
  token = var.hcloud_token != "" ? var.hcloud_token : local.hcloud_token
}

terraform {
  required_version = ">= 1.5.0"
  required_providers {
    hcloud = {
      source  = "hetznercloud/hcloud"
      version = ">= 1.43.0"
    }
  }
}

output "kubeconfig" {
  value     = module.kube-hetzner.kubeconfig
  sensitive = true
}

variable "hcloud_token" {
  sensitive = true
  default   = ""
}

Screenshots

image

Platform

Mac, Linux

mysticaltech commented 3 months ago

@dissy123 try just deleting that line:

lb_hostname = ""