https://rancher.com/ logo
#harvester
Title
# harvester
c

crooked-scooter-58172

11/04/2022, 2:47 AM
@here: We need to implement the the version management for VM images. Just checking what tool and process you guys are using to store VM images (I.e. git…etc)
👀 1
m

miniature-hairdresser-1087

11/04/2022, 10:43 AM
To store VM content? Or the config about them? We're extremely new to harvester, so we're planning on using terraform via the harvester provider to keep our configs in code.
c

crooked-scooter-58172

11/04/2022, 1:49 PM
Actually we are uploading VM images through UI. We need to manage these images in version control for Audits. Moreover we are looking a solution for 100+ images. Any advice please?
m

miniature-hairdresser-1087

11/04/2022, 2:48 PM
Ahh, I know you can also manage those via terraform. We're pulling in the various ubuntu/rocky cloud images that way.
Copy code
variable "guest_images" {
  type = map(any)
  default = {
    "22.04-amd64"   = "<https://cloud-images.ubuntu.com/releases/jammy/release/ubuntu-22.04-server-cloudimg-amd64.img>",
    "20.04-amd64"   = "<https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64.img>",
    "18.04-amd64"   = "<https://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img>",
    "16.04-amd64"   = "<https://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img>",
    "rocky9-amd64"  = "<https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-9.0-20220830.0.x86_64.qcow2>",
    "centos8-amd64" = "<https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.4.2105-20210603.0.x86_64.qcow2>"
  }
}

resource "harvester_image" "guest_images" {
  for_each  = var.guest_images
  name      = each.key
  namespace = "default"

  display_name = each.key
  source_type  = "download"
  url          = each.value
}
That will create vm images in harvester from those URLs.
c

crooked-scooter-58172

11/04/2022, 2:51 PM
Thanks @miniature-hairdresser-1087: So you guys are creating "VirtualMachineImage" CRD after this loop?
Something like this?
$ cat <<EOF | kubectl apply -f - apiVersion: harvesterhci.io/v1beta1 kind: VirtualMachineImage metadata: name: image-lvqxn namespace: default spec: displayName: opensuse-leap-15.3.x86_64-nocloud.qcow2 pvcName: "" pvcNamespace: "" sourceType: download url: http://download.opensuse.org/repositories/Cloud:/Images:/Leap_15.3/images/openSUSE-Leap-15.3.x86_64-NoCloud.qcow2 EOF
m

miniature-hairdresser-1087

11/07/2022, 11:45 AM
The Terraform creates the VirtualMachineImage in the cluster for us with the
resource "harvester_image" "guest_images" {}
stanza.
1
4 Views