kube-hetzner / terraform-hcloud-kube-hetzner

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

Find a way to allow the repo to work with either x86 or arm images only #1259

Closed roberto-sebastiano closed 8 months ago

roberto-sebastiano commented 8 months ago

Description

Hello,

NEED: As a maintaner of a cluster of arm only nodes, I would like the possiblity to have the repo working with only arm images. I tried commeting the x86 part in the packer file, but later terraform plan gives error about:

│ Error: no image found matching the selection
│
│   with module.kube-hetzner.data.hcloud_image.microos_x86_snapshot,
│   on .terraform/modules/kube-hetzner/main.tf line 6, in data "hcloud_image" "microos_x86_snapshot":
│    6: data "hcloud_image" "microos_x86_snapshot" {

This is true even if I pinpoint the same arm image like microos_x86_snapshot_id = "123456" microos_arm_snapshot_id = "123456" where 123456 is present on hetzner cloud as a packer snapshot

PROPOSED SOLUTION: something in the line of (see count):

main.tf

data "hcloud_image" "microos_x86_snapshot" {
  count = var.microos_x86_snapshot_id == null ? 0 : 1

  with_selector     = "microos-snapshot=yes"
  with_architecture = "x86"
  most_recent       = true
}

probably this would need to be patched in other files as well, I can provide a PR if needed ❤️

Roberto Sebastiano

mysticaltech commented 8 months ago

@roberto-sebastiano You can have your cluster 100% ARM, it's what I use actually, no problem at all. The snapshot does not cost anything, don't worry about it.

roberto-sebastiano commented 8 months ago

@mysticaltech I don't agree at all.

It takes time to build with packer 2 images each time you test something when you need just one ! Please reopen the bug as a feature request

Thank you Roberto Sebastiano

mysticaltech commented 8 months ago

@roberto-sebastiano Why would you build each time? I haven't built mine in the last 6 months.

Also, please PR welcome if you find a way. The problem is that packer and terraform are not connected, so that was the simpler solution we could find. You may want to customize the code to work for you just with ARM, but it's just not easily generalizable.